Search code examples
pythonsoftware-distribution

How to distribute a Python program with external libraries


I have a Python program that uses the following libraries: Tkinter, NumPy, SciPy, SymPy, and Matplotlib. And probably it will include more libraries in the near future while being developed.

How can I distribute such a program to Mac, Windows, and Linux users, without requiring users to install the right version of each library, and hopefully by just downloading a single file and executing it?

What I initially wanted was compiling the program into a static binary program, but it seems that it's not an easy goal.

Probably I can ask users to install Python, but that's the maximum requirement that I can ask for them, and I want to avoid it if possible.

I don't care about hiding the code at all; in the end I will distribute both the code and the program. What I want is to make the program very easy for any user to download and run it.

Even such an advice as 'a Python program is not suitable for such a distribution' is welcome. I had a fair amount of experience with distributing C programs but I don't know what to expect with a Python program.


Solution

  • For convenient, you could try something like pyinstaller. It will package all of needed module into one folder or or one executable as you like. And it can run in all platforms.

    The simple command to make a directory contains an executable file and all needed library is

    $pyinstaller --onedir --name=directory_name --distpath="path_to_put_that_directory" "path to your main_program.py"
    

    You can change --onedir into --onefile to make that folder into an one executable file which has all the thing it need to run inside.