Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to convert Python script to EXE using PyInstaller

📅 2011-Jun-02 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ pyinstaller, python, windows 7 ⬩ 📚 Archive

 

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