简体   繁体   English

PyInstaller将我的python脚本构建为可执行文件,但是不起作用

[英]PyInstaller built my python scripts to executable file, but it doesn't work

I am using PyInstaller to create an executable file. 我正在使用PyInstaller创建可执行文件。

My spec file is as follows: 我的规格文件如下:

# -*- mode: python -*-
import sys

a = Analysis(['maingui.py'],
         hiddenimports=[],
         hookspath=None)
for d in a.datas:
    if 'pyconfig' in d[0]: 
    a.datas.remove(d)
    break
pyz = PYZ(a.pure)
exe = EXE(pyz,
      a.scripts,
      a.binaries,
      a.zipfiles,
      a.datas + [('scheme_1e1s.png', '.\\scheme_1e1s.png', 'DATA')],
      [('scheme_2e1s.png', '.\\scheme_2e1s.png', 'DATA')],
      [('scheme_2e2s.png', '.\\scheme_2e2s.png', 'DATA')],
      [('scheme_2ew1s.png', '.\\scheme_2ew1s.png', 'DATA')],
      [('scheme_3e1s.png', '.\\scheme_3e1s.png', 'DATA')],
      [('scheme_3e1s_inter.png', '.\\scheme_3e1s_inter.png', 'DATA')],
      [('scheme_3e1s_series.png', '.\\scheme_3e1s_series.png', 'DATA')],
      [('scheme_3e2s.png', '.\\scheme_3e2s.png', 'DATA')],
      [('scheme_3e2s_inter.png', '.\\scheme_3e2s_inter.png', 'DATA')],
      [('scheme_3e2s_series.png', '.\\scheme_3e2s_series.png', 'DATA')],
      [('chinese.qm', '.\\chinese.qm', 'DATA')],
      [('spanish.qm', '.\\spanish.qm', 'DATA')],
      name=os.path.join('dist', 'maingui.exe'),
      debug=False,
      strip=None,
      upx=True,
      console=True)

app = BUNDLE(exe,
      name='maingui.exe.app',
      icon=None)

And when I run PyInstaller, then it generates exe file to dist successfully. 并且当我运行PyInstaller时,它会成功生成exe文件以将dist成功。

c:\bin\chem>pyinstaller --clean maingui.spec
39 INFO: Testing for ability to set icons, version resources...
72 INFO: ... resource update available
76 INFO: UPX is not available.
101 INFO: Processing hook hook-os
222 INFO: Processing hook hook-time
227 INFO: Processing hook hook-cPickle
300 INFO: Processing hook hook-_sre
434 INFO: Processing hook hook-cStringIO
539 INFO: Processing hook hook-encodings
552 INFO: Processing hook hook-codecs
993 INFO: Removing temporary files and cleaning cache in C:\Users\super2lao\AppData\Roaming\pyinstal
ler
1161 INFO: Extending PYTHONPATH with c:\bin\chem
1161 INFO: checking Analysis
1161 INFO: building Analysis because out00-Analysis.toc non existent
1161 INFO: running Analysis out00-Analysis.toc
1162 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
1296 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
1296 INFO: Found manifest C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.
21022.8_none_750b37ff97f4f68b.manifest
1297 INFO: Searching for file msvcr90.dll
1299 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_7
50b37ff97f4f68b\msvcr90.dll
1299 INFO: Searching for file msvcp90.dll
1299 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_7
50b37ff97f4f68b\msvcp90.dll
1299 INFO: Searching for file msvcm90.dll
1299 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_7
50b37ff97f4f68b\msvcm90.dll
1401 INFO: Analyzing c:\bin\Python27\lib\site-packages\PyInstaller\loader\_pyi_bootstrap.py
1412 INFO: Processing hook hook-os
1428 INFO: Processing hook hook-site
1447 INFO: Processing hook hook-encodings
1570 INFO: Processing hook hook-time
1573 INFO: Processing hook hook-cPickle
1651 INFO: Processing hook hook-_sre
1783 INFO: Processing hook hook-cStringIO
1907 INFO: Processing hook hook-codecs
2370 INFO: Processing hook hook-pydoc
2509 INFO: Processing hook hook-email
2573 INFO: Processing hook hook-httplib
2616 INFO: Processing hook hook-email.message
2684 INFO: Analyzing c:\bin\Python27\lib\site-packages\PyInstaller\loader\pyi_importers.py
2736 INFO: Analyzing c:\bin\Python27\lib\site-packages\PyInstaller\loader\pyi_archive.py
2783 INFO: Analyzing c:\bin\Python27\lib\site-packages\PyInstaller\loader\pyi_carchive.py
2832 INFO: Analyzing c:\bin\Python27\lib\site-packages\PyInstaller\loader\pyi_os_path.py
2839 INFO: Analyzing maingui.py
2953 INFO: Processing hook hook-PySide
3226 INFO: Processing hook hook-matplotlib
12008 INFO: Processing hook hook-matplotlib.backends
13428 INFO: Processing hook hook-parser
13579 INFO: Processing hook hook-distutils
14027 INFO: Processing hook hook-setuptools
14319 INFO: Processing hook hook-sysconfig
14351 INFO: Processing hook hook-xml
14416 INFO: Processing hook hook-xml.sax
14450 INFO: Processing hook hook-pyexpat
14529 INFO: Processing hook hook-win32com
14537 INFO: Processing hook hook-win32com.client
14553 INFO: Processing hook hook-pythoncom
14620 INFO: Processing hook hook-pywintypes
14774 INFO: Processing hook hook-win32ui
15550 INFO: Processing hook hook-scipy.sparse.csgraph
16533 INFO: Processing hook hook-PyQt4
16536 INFO: Processing hook hook-PyQt4.QtGui
17297 INFO: Processing hook hook-PyQt4.QtCore
18200 INFO: Hidden import 'codecs' has been found otherwise
18201 INFO: Hidden import 'encodings' has been found otherwise
18201 INFO: Looking for run-time hooks
18203 INFO: Analyzing rthook c:\bin\Python27\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_qt
4plugins.py
18247 INFO: Analyzing rthook c:\bin\Python27\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_mp
lconfig.py
18304 INFO: Analyzing rthook c:\bin\Python27\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_mp
ldata.py
18347 INFO: Analyzing rthook c:\bin\Python27\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_pk
gres.py
18494 INFO: Analyzing rthook c:\bin\Python27\lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_wi
n32comgenpy.py
28392 INFO: Adding Microsoft.VC90.MFC to dependent assemblies of final executable
28521 INFO: Searching for assembly amd64_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
28523 INFO: Found manifest C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0
.21022.8_none_706fccb39ad7e580.manifest
28524 INFO: Searching for file mfc90.dll
28526 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_
706fccb39ad7e580\mfc90.dll
28526 INFO: Searching for file mfc90u.dll
28526 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_
706fccb39ad7e580\mfc90u.dll
28527 INFO: Searching for file mfcm90.dll
28527 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_
706fccb39ad7e580\mfcm90.dll
28534 INFO: Searching for file mfcm90u.dll
28536 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_
706fccb39ad7e580\mfcm90u.dll
32259 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
32444 INFO: Using Python library C:\Windows\system32\python27.dll
32641 INFO: Warnings written to c:\bin\chem\build\maingui\warnmaingui.txt
32684 INFO: checking PYZ
32685 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
32686 INFO: building PYZ (ZlibArchive) out00-PYZ.toc
38406 INFO: checking PKG
38407 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
38407 INFO: building PKG (CArchive) out00-PKG.pkg
80056 INFO: checking EXE
80057 INFO: building because out00-EXE.toc missing or bad
80059 INFO: building EXE from out00-EXE.toc
80093 INFO: Appending archive to EXE c:\bin\chem\dist\maingui.exe

c:\bin\chem>

By the way, I get following error and it is my great difficulty. 顺便说一句,我遇到以下错误,这是我的最大困难。

c:\bin\chem>dist\maingui.exe
Traceback (most recent call last):
  File "<string>", line 7, in <module>
  File "c:\bin\Python27\lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_mo
dule
    exec(bytecode, module.__dict__)
  File "c:\bin\chem\build\maingui\out00-PYZ.pyz\PySide", line 41, in <module>
  File "c:\bin\chem\build\maingui\out00-PYZ.pyz\PySide", line 11, in _setupQtDirectories
  File "c:\bin\chem\build\maingui\out00-PYZ.pyz\PySide._utils", line 93, in get_pyside_dir
  File "c:\bin\Python27\lib\site-packages\PyInstaller\loader\pyi_importers.py", line 409, in load_mo
dule
    module = imp.load_module(fullname, fp, filename, self._c_ext_tuple)
RuntimeError: the sip module has already registered a module called PyQt4.QtCore

c:\bin\chem>

What is wrong? 怎么了?

I fixed this problem. 我解决了这个问题。 There was an error in spec file. 规格文件中存在错误。 pyinstaller maingui.py This command generates a spec file. pyinstaller maingui.py此命令生成规范文件。 I used this, and get a running exe file. 我用了它,并得到了一个正在运行的exe文件。

I am glad to fix the issues. 我很高兴解决这些问题。

Regards. 问候。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PyInstaller:单文件可执行文件不起作用 - PyInstaller: Single-file executable doesn't work 我正在使用 pyinstaller 使我的 python 文件可执行。 我在文件中使用 tkvideo。 我在同一目录中有mp4。 它不起作用 - I'm using pyinstaller to make my python file executable. I am using tkvideo inside the file. I have the mp4 in the same directory. It doesn't work 用PyInstaller创建的Python可执行文件无法运行 - Python executable created with PyInstaller doesn't run 使用pyinstaller使其成为可执行文件后,无法在Python中移动文件 - Moving files in Python doesn't work once made executable using pyinstaller pyinstaller:当我用pyinstaller制作.exe文件时,在python中使用内置函数打开的可执行文件关闭1秒 - Pyinstaller: Executable file opened with built in function in python closes after 1 sec when i make .exe file with pyinstaller PyInstaller:单文件可执行文件不运行 - PyInstaller: Single-file executable doesn't run 我的exe 从 pyinstaller 创建的文件不像它是 .py 时那样工作(Pyexcel 问题) - My exe. file created from pyinstaller doesn't work like it does when it was .py (Pyexcel problem) pyinstaller没有读取我的钩子文件,并且不能与win32com.shell一起使用 - pyinstaller not reading my hook file and doesn't work with win32com.shell pyinstaller可执行文件未在Ubuntu 18.04.1中运行 - pyinstaller executable doesn't run in Ubuntu 18.04.1 使用 pyinstaller 分发我的 TKinter 应用程序不起作用 - Distributing my TKinter app with pyinstaller doesn't work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM