How do I compile a PyQt script (.py) to a single standalone executable file for windows (.exe) and/or linux?

pyinstaller pyqt
python compile to exe
pyqt5 exe
python standalone executable
fbs python
python exe builder
fbs freeze
fbs qt python

I started to fiddle with PyQt, and made a "beautiful" script from the pyqt whitepaper example app (pastebin)

It works perfectly in Windows and Linux (with qt environment already installed on both).

Now my question is: Since I am trying to use Qt because it is compiled (at least pure old C++ based Qt), how can I compile some .exe file to run it on Windows, or a standalone executable for Linux.

The point is that I want the program to be compiled, because of speed and portability, instead of interpreted from source, which would require a previous setup on any machine. One of the goals, for example, is sending small gui scripts via email to coworkers who are not programmers at all.

if you want completelly create one stand alone executable, you can try this : . i feel it's better to create one stand alone executable than cx_freeze or py2exe (in my experience). and easy to use (full documentation available in the site).

Update: As latest information from @SoursopTree and @LectureMaker, it now support python version 3.3 - 3.6.

Update: pass --onefile argument if you want to create completely standalone .exe. in example :

pyinstaller.exe --onefile --windowed

Update: Another interesting library which Author of the library claims that you could Create cross-platform desktop apps. its worth to try

PyQt/Deploying_PyQt_Applications, it is compiled (at least pure old C++ based Qt), how can I compile some .exe file to run it on Windows, or a standalone executable for Linux. After customizing the spec file and running PyInstaller, we now have a nice executable file. A .app on macOS, a .exe on Windows, and an executable file on Linux. The next step is to package it into something that users are used to downloading. 3.1 Creating a .dmg for macOS

After spending many weeks on this and trying all the alternatives - PyInstaller, py2exe, cx_freeze,... - I created my own library: It is based on PyInstaller but solves many of its common pain points. It also lets you create native installers on Windows, Mac and Linux.

PyQt exe creation, Creates stand-alone executables and installers for PyQt applications. (​packages) Python programs into stand-alone executables, under Windows, Linux and Irix." "ExeMaker is a small tool that takes a Python script, copies it to a program directory, and creates a Windows EXE file in the same directory."  Compile Standalone executable. In order to get .exe you have to run pyinstaller on Windows, to get Linux or Mac standalone, you have to compile your script on the corresponding platform. On Windows: Usually, I would use this line to compile fairly simple python scripts to standalone executables. Run the following command in cmd:

You may want to check out cx_freeze. It claims to create executables which are "cross platform and should work on any platform that Python itself works on."

I came across it in exploring the moneyGuru package which uses PyQt. I downloaded the moneyguru.exe file to my Windows XP system, executed it, and it worked fine on Python 3.2.

You can clone the hg repo from here to see how it.s done.

Making a Stand Alone Executable from a Python Script Using , Build a stand-alone executable for your PyQt application on Windows. describes how you can compile an existing PyQt application to a self-contained .​exe on Windows. You will likely have a script with code similar to the following: To access the image file, we use the application context's .​get_resource(. I'm building a Python application and don't want to force my clients to install Python and modules. So, is there a way to compile a Python script to be a standalone executable?

Since I am trying to use Qt because it is compiled

You're defeating this benefit by using Python. Although the other answers give an introduction to the options for distributing Python code without requiring users to install Python themselves, Python is intended to be an interpreted language so there will be downsides to each of these options (ex. speed, program size, compatibility, etc...). They may or may not be deal-breakers to you.

Your two other options are:

  1. Embrace the interpreted nature of Python: have people you're sharing your program with install Python and the dependencies. You can simplify this process significantly though. Ex. on Linux, use a package manager.
  2. Write your program in C++. Doing so would allow you to truly compile a single, native executable. This unfortunately means dropping Python, but there's reasons people still write code in less beautiful languages like C++ and it sounds like you might be running into some of them.

How to convert .py to .exe? Step by step guide., to use Qt because it is compiled (at least pure old C++ based Qt), how can I compile some .exe file to run it on Windows, or a standalone executable for Linux​. Deploying PyQt Applications. This page contains information about some of the tools that could be used to deploy PyQt applications on various platforms, typically in binary form. The idea is that each solution should be listed along with a brief description and a link to its home page.

There is a module named Py2EXE, which will do exactly what you want to do. It will convert the script into a .exe file to run on windows. I'm not sure about linux, but I bet there is a module out there somewhere.

How to Convert Python Files into Executables, This argument tells PyInstaller to create only one file. You can only create executable for your Operating system, i.e. the Operating system you used to compile the executable. For example, it is not possible to create a Windows executable (.exe) by directly running a Pyinstaller command on a Linux  The creation of an executable using pyinstaller is very straightforward, customizable and very easy to do. In our example, we are going to create an executable of the following script. The filename of the script is and contains the following code (it just prompt the user for the name of a new file and the content):

Freezing Your Code, Auto PY to EXE is an amazing application for making .exe file out of your If you have multiple files choose one that starts the program. If your program has only default Windows gui with no icons, backgrounds, media files or you are If you'​re looking to build performant executables and Python is what  I downloaded your exe and unfortunately for me it still crashes on doing a compile for a single .py file. When you make your next commit, change one line in the .spec file so we can see the failures for now.

Creating a Stand Alone Executable from a Python Script using , a stand-alone executables under Windows, GNU/Linux, Mac OS X, FreeBSD, This will build file in a couple of seconds, here is my resulting folders: A 5.5MB single executable .exe file, the file size will differ depending on the Writing a server and client Python scripts that receives and sends files in the  Step 4: Testing your executable code. There should be a file in your current directory called (the one we created just moments ago) and a new executable file called sample.exe which, although confusingly similarly named as if it were a Windows executable, it is a normal Linux executable binary.

“Freezing” your code is creating a single-file executable file to distribute to On Windows, and even on many Linux distributions and OS X, the right exe that bundles the appropriate DLL when passing --onefile to . from distutils.core import setup import py2exe setup( windows=[{'script': ''}], ). It supports Python 2.7 and Python 3.4+ and successfully bundles the major and famous Python packages such as numpy, PyQT, Django and more. PyInstaller isn't cross-compiler, which means if you want to make a Windows executable (.exe), you need to run Pyinstaller on Windows, and if you want a GNU/Linux app, you do the same, etc.

  • I'd say… answers your question for windows.
  • For Linux and Mac OS X, there is this question here on SO:
  • Did you get it to work? I have a similar question here:…
  • @DuhCompewtuhr Unfortunately I have not made additional attempts or projects, and still use PyGtk whenever I need some simple GUI stuff.
  • Possible duplicate of How to make an executable file in Python?
  • Hey..., Good news! It is now support python 3.3 – 3.5.
  • Why don't you update the answer to mention it supports python 3? Not everyone read comments :)
  • I see that pyinstaller now supports Python 3.6 as well: Multi-version: supports Python 2.7 and Python 3.3—3.6.
  • @YudaPrawira: Is it possible to run the executable made by pyinstaller to run on machine, which doesn't have pyqt installed? I am trying to deploy a pyqt5 application and is facing issue...
  • @Abin Please check here… I thought you can use --hidden-import command option. worth to try.
  • O'Donnel: "the moneyguru.exe file (...) worked fine on Python 3.2". Don, I didn't understand this. You ran a .exe file on Python? You used cx_freeze to compile the py sources to get .exe file? Or someting else? Thanks!
  • @heltonbiker: Sorry about the confusion. The download file is moneyGuru_win_2_3_7.exe. When you execute that it creates a directory in C:\Program Files called Hardcoded Software, this contains (among others) the file moneyGuru.exe which starts the Python app.
  • @heltonbiker: I haven't tried to install the Linus or Mac versions but I expect they operate in a similar manner.
  • I know about this module, but I am not sure it is equivalent to create an identical app in native qt and compile it. Sorry if what I want does not make sense. I will try to compile the script it with py2exe and post results here. Thanks for now!