我有一个使用 Python 2.7 和 PyQt4 构建的 GUI 程序。我想将其转换为独立的 Windows 可执行文件。
我浏览了 Pyinstaller-2.0 的文档并尝试了几次,但我认为我可能采用了错误的方法。
这是我的程序的结构。
[资源] #包含图标的图像
[Hunspell] #包含程序特定文件
[stylesheets] #包含主题相关文件
资源.py
设计.py
主文件
前三个是包含程序运行所需文件的文件夹。文件 main.py 导入其他两个以正常运行。我该怎么做才能制作出完美的可执行文件?
我尝试了以下方法:
python pyinstaller.py -w main.py
并得到以下警告文件。
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)
我的终端输出如下
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