Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building executables for Python 3 and PyQt

Tags:

I built a rather simple application in Python 3.1 using PyQt4. Being done, I want the application to be distributed to computers without either of those installed.

I almost exclusively care about Windows platforms, so my goal is to have a single executable file and maybe some resource files and .dlls in the end.

Having searched around, I came to the conclusion that

  • py2exe only supports Python up to version 2.7
  • pyinstaller only supports Python up to version 2.6
  • cx_Freeze does not work for me because I keep on getting the following error when trying to execute my successfully build binary:

Y:\Users\lulz\build\exe.win32-3.1>system_shutdown.exe
Traceback (most recent call last):
File "Y:\Program Files (x86)\Python\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 27, in exec(code, m.__dict__)
File "Y:/Users/lulz/Documents/Coding/Python3/projects/System Shutdown/system_shutdown.pyw", line 5, in from PyQt4 import QtCore
File "ExtensionLoader_PyQt4_QtCore.py", line 16, in AttributeError: 'NoneType' object has no attribute 'modules'

So my problem is basically two problems here:

  1. Is there another way but cx_Freeze to build binaries with my configuration?
  2. If not, what might the cx_Freeze problem be?

I can provide more information on the second problem if necessary, like my call of cx_Freeze, my distutils setup script etc.

Thank you already for your help and comments.

like image 304
WrongAboutMostThings Avatar asked Nov 15 '09 12:11

WrongAboutMostThings


People also ask

Does PyInstaller work with PyQt5?

PyInstaller works out of the box with PyQt5 and as of writing, current versions of PyInstaller are compatible with Python 3.6+. Whatever project you're working on, you should be able to package your apps. You can install PyInstaller using pip .

How do I run an auto py file in exe?

First visit the GitHub page for this library and download the code using the download ZIP option as shown in the image below. Next extract the file, locate the python file called run.py and execute it. This should open up the interface for auto-py-to-exe.


1 Answers

You can fix this by appending one line of code to freeze.py in your cx_Freeze package.

It is described here: http://www.mail-archive.com/[email protected]/msg00212.html

It worked for me at least :)

Cheers, Almar

like image 175
Almar Avatar answered Sep 27 '22 19:09

Almar