How to convert Python script to EXE using PyInstaller

Converting a Python script into a EXE file is a convenient way to share it among other computers or users who do not have Python installed. PyInstaller makes this process really easy! Here is how:

  1. Download and unzip PyInstaller. It is not a Python library, so it does not need to be installed into Python. Let us assume the unzipped files are placed in C:\PyInstaller
  2. Open a Command Prompt in the PyInstaller directory and configure it using: python Configure.py
  3. Open a Command Prompt in the directory containing your Python script (say Foo.py). I assume you want to convert it into a single EXE file. Create a spec file for Foo.py by using: python C:\PyInstaller\Makespec.py --onefile Foo.py This generates a Foo.spec file.
  4. Build the EXE file for Foo.py by using: python C:\PyInstaller\Build.py Foo.spec
  5. Your Foo.exe file is now ready for distribution and can be found in the dist directory! 🙂

Tried with: PyInstaller 1.5, Python 2.7 and Windows 7

Advertisements

5 thoughts on “How to convert Python script to EXE using PyInstaller

  1. I’m on windows, and “python scripname.py” never works for me. It always says that no batch script named “python” can be found. so ive been using another trick. “scriptname.py install” & its always worked, but its not working with this.

    Any help?

    Like

  2. This is very badly explained. Nothing works no matter how I follow the above instructions. Whatever I type into the command line it comes back saying that it is not recognized as an internal or external command or operableor program or batch file.

    Like

  3. Hi, I’ve just read this tutorial and I’m wondering (once the python program has been converted to .exe) what if I modify some of my scripts and / or add a new script, is there a way to “compile” or “update” the .exe only with those new / modified scripts?

    Thanks a lot

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.