0

I have a certain GUI program that I built using Python 2.7 and PyQt4. I want to convert it into a standalone windows executable.

I went through the docs for Pyinstaller-2.0 and tried several times but I think that I might be on the wrong approach.

Here is the structure of my Program.

[Resources] #contains images of icons

[Hunspell] #contains program specific files

[stylesheets] #contains theme related files

resources.py

design.py

main.py

The first three are folders containing necessary files for the program to run. The file main.py imports the other two to run properly. What do I do to go towards making the perfect executable?

I tried the following :

python pyinstaller.py -w main.py

and got the following warning file.

W: no module named _subprocess (conditional import by subprocess)
W: no module named PyQt4.QtOpenGL (top-level import by PyQt4.Qt)
W: no module named PyQt4._qt (top-level import by PyQt4.QtXml)
W: no module named cl (delayed, conditional import by aifc)
W: no module named _sha (delayed, conditional import by hashlib)
W: no module named _winreg (top-level import by mimetypes)
W: no module named PyQt4._qt (top-level import by PyQt4.QtNetwork)
W: no module named org (top-level import by pickle)
W: no module named _sha512 (delayed, conditional import by hashlib)
W: no module named nt (delayed, conditional import by __main__)
W: no module named msvcrt (conditional import by getpass)
W: no module named PyQt4.Qt3Support (top-level import by PyQt4.Qt)
W: no module named AES (delayed, conditional import by archive)
W: no module named _scproxy (conditional import by urllib)
W: no module named EasyDialogs (conditional import by getpass)
W: no module named PyQt4._qt (top-level import by PyQt4.QtCore)
W: no module named nt (top-level import by ntpath)
W: no module named org (top-level import by copy)
W: no module named _md5 (delayed, conditional import by hashlib)
W: no module named msvcrt (conditional import by subprocess)
W: no module named PyQt4._qt (top-level import by PyQt4.QtSvg)
W: no module named SOCKS (top-level import by ftplib)
W: no module named PyQt4._qt (top-level import by PyQt4.QtGui)
W: no module named msvcrt (delayed import by getpass)
W: no module named cl (delayed import by aifc)
W: no module named PyQt4._qt (top-level import by PyQt4.QtAssistant)
W: no module named _emx_link (conditional import by os)
W: no module named PyQt4._qt (top-level import by PyQt4.QtTest)
W: no module named _sha256 (delayed, conditional import by hashlib)
W: no module named PyQt4.QtSql (top-level import by PyQt4.Qt)
W: no module named PyQt4._qt (top-level import by PyQt4.Qt)
W: no module named PyQt4._qt (top-level import by PyQt4.QtWebKit)
W: no module named PyQt4._qt (top-level import by PyQt4)
W: no module named rourl2path (conditional import by urllib)
W: no module named _winreg (delayed import by urllib)
W: no module named Crypt (delayed, conditional import by __main__)
W: no module named AES (delayed, conditional import by __main__)
W: __all__ is built strangely at line 0 - dis (/usr/lib/python2.7/dis.pyc)
W: delayed  exec statement detected at line 0 - bdb (/usr/lib/python2.7/bdb.pyc)
W: delayed  eval hack detected at line 0 - bdb (/usr/lib/python2.7/bdb.pyc)
W: delayed  eval hack detected at line 0 - bdb (/usr/lib/python2.7/bdb.pyc)
W: delayed  __import__ hack detected at line 0 - optparse (/usr/lib/python2.7/optparse.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (/usr/lib/python2.7/doctest.pyc)
W: delayed  exec statement detected at line 0 - doctest (/usr/lib/python2.7/doctest.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (/usr/lib/python2.7/doctest.pyc)
W: __all__ is built strangely at line 0 - regex (/usr/local/lib/python2.7/dist-packages/regex.pyc)
W: __all__ is built strangely at line 0 - tokenize (/usr/lib/python2.7/tokenize.pyc)
W: __all__ is built strangely at line 0 - tokenize (/usr/lib/python2.7/tokenize.pyc)
W: delayed  __import__ hack detected at line 0 - pickle (/usr/lib/python2.7/pickle.pyc)
W: delayed  __import__ hack detected at line 0 - pickle (/usr/lib/python2.7/pickle.pyc)
W: delayed  __import__ hack detected at line 0 - encodings (/usr/lib/python2.7/encodings/__init__.pyc)
W: __all__ is built strangely at line 0 - hashlib (/usr/lib/python2.7/hashlib.pyc)
W: delayed conditional eval hack detected at line 0 - warnings (/usr/lib/python2.7/warnings.pyc)
W: delayed conditional __import__ hack detected at line 0 - warnings (/usr/lib/python2.7/warnings.pyc)
W: delayed  __import__ hack detected at line 0 - email (/usr/lib/python2.7/email/__init__.pyc)
W: delayed  exec statement detected at line 0 - pdb (/usr/lib/python2.7/pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (/usr/lib/python2.7/pdb.pyc)
W: delayed  eval hack detected at line 0 - pdb (/usr/lib/python2.7/pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (/usr/lib/python2.7/pdb.pyc)
W: delayed  eval hack detected at line 0 - pdb (/usr/lib/python2.7/pdb.pyc)
W: delayed conditional exec statement detected at line 0 - iu (/home/kuro/Desktop/notepad (copy)/PyInstaller/loader/iu.pyc)
W: delayed conditional exec statement detected at line 0 - iu (/home/kuro/Desktop/notepad (copy)/PyInstaller/loader/iu.pyc)
W: __all__ is built strangely at line 0 - collections (/usr/lib/python2.7/collections.pyc)
W: delayed  exec statement detected at line 0 - collections (/usr/lib/python2.7/collections.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.main (/usr/lib/python2.7/unittest/main.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (/usr/lib/python2.7/unittest/loader.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (/usr/lib/python2.7/unittest/loader.pyc)
W: delayed  __import__ hack detected at line 0 - unittest.loader (/usr/lib/python2.7/unittest/loader.pyc)
W: __all__ is built strangely at line 0 - __future__ (/usr/lib/python2.7/__future__.pyc)
W: delayed  eval hack detected at line 0 - gettext (/usr/lib/python2.7/gettext.pyc)

And my terminal output is as follows

8 INFO: wrote /home/kuro/Desktop/notepad (copy)/main/main.spec
25 INFO: UPX is not available.
645 INFO: checking Analysis
645 INFO: building Analysis because out00-Analysis.toc non existent
645 INFO: running Analysis out00-Analysis.toc
716 INFO: Analyzing /home/kuro/Desktop/notepad (copy)/support/_pyi_bootstrap.py
1311 INFO: Analyzing /home/kuro/Desktop/notepad (copy)/PyInstaller/loader/archive.py
1377 INFO: Analyzing /home/kuro/Desktop/notepad (copy)/PyInstaller/loader/carchive.py
1419 INFO: Analyzing /home/kuro/Desktop/notepad (copy)/PyInstaller/loader/iu.py
1433 INFO: Analyzing main.py
2116 INFO: Hidden import 'encodings' has been found otherwise
2116 INFO: Looking for run-time hooks
2117 INFO: Analyzing rthook /home/kuro/Desktop/notepad (copy)/support/rthooks/pyi_rth_qt4plugins.py
2156 INFO: Analyzing rthook /home/kuro/Desktop/notepad (copy)/support/rthooks/pyi_rth_encodings.py
4514 INFO: Looking for Python library libpython2.7.so
objdump: section '.dynamic' mentioned in a -j option, but not found in any input file
4744 INFO: Warnings written to /home/kuro/Desktop/notepad (copy)/main/build/pyi.linux2/main/warnmain.txt
4753 INFO: checking PYZ
4754 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
4754 INFO: building PYZ out00-PYZ.toc
6724 INFO: checking PKG
6724 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
6724 INFO: building PKG out00-PKG.pkg
6743 INFO: checking EXE
6743 INFO: rebuilding out00-EXE.toc because main missing
6743 INFO: building EXE from out00-EXE.toc
6772 INFO: Appending archive to EXE /home/kuro/Desktop/notepad (copy)/main/build/pyi.linux2/main/main
6782 INFO: checking COLLECT
6783 INFO: building COLLECT out00-COLLECT.toc
Community
  • 1
  • 1

1 Answers1

0

I believe you need to edit your .spec file to include your three folders for data collection. These will then be collected into the compiled executable and extracted out to the temp folder with the rest of the python libraries and files.

To simply add a folder just add the below under the a = Analysis section:

a.datas += Tree('/home/kuro/Desktop/notepad/Resources', prefix='Resources')

See solutions:

This is a spec file from one of my projects. It includes version.txt for exe version info, an icon, and UPX.

# -*- mode: python -*-
a = Analysis(['CleanUp.py'],
             pathex=[''],
             hiddenimports=[],
             hookspath=None,
             runtime_hooks=None)
a.datas += Tree('D:\\Projects\\cleanup\\data', prefix='data')
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='CleanUp.exe',
          debug=False,
          strip=None,
          upx=True,
          console=True , version='version.txt', icon='trash.ico')
Community
  • 1
  • 1