Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create windows installer for pyqt project

Tags:

python

qt

pyqt4

How can I convert my python program with Qt for GUI to .exe file??

I want to make an installation file for my python source code

like image 561
Juan Lopez Avatar asked May 18 '12 21:05

Juan Lopez


1 Answers

First part : "How can I convert my python program with Qt for GUI to .exe file??"

You can use PyInstaller, which supports python 2.2 - 2.7 and it has a hook system for including Qt with all dlls and plugins.

You can use also :

  • bbfreeze
  • cxfreeze
  • py2exe (pretty old)
  • esky (a wrapper of all the above except PyInstaller)

Basically all this systems have a definition file to handle and produce the binary package. For instance, esky has a setup.py (which is a distutil file) to produce the package :

from esky import bdist_esky
from distutils.core import setup

setup(name="appname",
      version="1.2.3",
      scripts=["appname/script1.py","appname/gui/script2.pyw"],
      options={"bdist_esky":{"includes":["mylib"]}},
     )

Than you can call "python setup.py bdist_esky"

For PyInstaller the thing is pretty different. From console, cd in PyInstaller folder :

python Makespec.py  [options] script.py

This produce a spec file with all the options to package your script. You can also modify this file with an editor.

python Build.py  script.spec

This analyzes and builds your exe (or os binary equivalent).

Second part : "I want to make an installation file for my python source code"

You have to use NSIS, InnoSetup, BitRock Installer, IzPack or equivalent to produce a platform installer. So you have to take the binary result produced on the first part and package it for os distribution. Almost all the installer systems are thought for Windows systems. Cross platform : Zero Install, IzPack ... If you use IzPack you can have a cross platform installer paying the price of including a jvm.

like image 142
J_Zar Avatar answered Sep 19 '22 12:09

J_Zar