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

  3. Open a Command Prompt in the directory containing your Python script (say I assume you want to convert it into a single EXE file. Create a spec file for by using: python C:\PyInstaller\ --onefile This generates a Foo.spec file.

  4. Build the EXE file for by using: python C:\PyInstaller\ 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