我只想尝试使用Pyinstaller构建.exe。这是我的plot.py代码
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
效果很好。
然后我pythoninstaller plot.py
,它运行如下,似乎很好,但是当你点击plot.exe时,它将很快结束,没有图片,没有任何错误。
(注意我使用Pycharm来完成所有这些,Pyinstaaller的版本是3.2)
544 INFO: PyInstaller: 3.1.1
546 INFO: Python: 2.7.11
548 INFO: Platform: Windows-10-10.0.10586
559 INFO: wrote C:\Python27\Lib\site-packages\GUI_tempCtrl\plot.spec
634 INFO: UPX is not available.
703 INFO: Extending PYTHONPATH with paths
['C:\\Python27\\Lib\\site-packages\\GUI_tempCtrl',
'C:\\Python27\\Lib\\site-packages\\GUI_tempCtrl']
717 INFO: checking Analysis
745 INFO: Building Analysis because out00-Analysis.toc is non existent
746 INFO: Initializing module dependency graph...
844 INFO: Initializing module graph hooks...
1407 INFO: running Analysis out00-Analysis.toc
1446 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
required by C:\Python27\python.exe
3288 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest
3299 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4137_none_f47d3254f657e518.manifest
3345 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_f47e1bd6f6571810.manifest
3421 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_f480bfaef65491a5.manifest
3500 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_f4813cfaf6543c37.manifest
6450 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.9177_none ...
6658 INFO: Found manifest C:\WINDOWS\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9.manifest
6798 INFO: Searching for file msvcr90.dll
6874 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9\msvcr90.dll
6888 INFO: Searching for file msvcp90.dll
6894 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9\msvcp90.dll
6936 INFO: Searching for file msvcm90.dll
6967 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9\msvcm90.dll
11110 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest
11173 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4137_none_f47d3254f657e518.manifest
11203 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_f47e1bd6f6571810.manifest
11338 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_f480bfaef65491a5.manifest
11410 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_f4813cfaf6543c37.manifest
11531 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9177)
13181 INFO: Analyzing C:\Python27\Lib\site-packages\GUI_tempCtrl\plot.py
16867 INFO: Processing pre-find module path hook distutils
137003 INFO: Processing pre-safe import module hook _xmlplus
159687 INFO: Processing pre-find module path hook site
159687 INFO: site: retargeting to fake-dir 'C:\\Python27\\lib\\site-packages\\pyinstaller-3.1.1-py2.7.egg\\PyInstaller\\fake-modules'
159763 INFO: Processing pre-safe import module hook win32com
165181 INFO: Processing pre-safe import module hook six.moves
174332 INFO: Looking for import hooks ...
174345 INFO: Processing hook hook-distutils.py
174348 INFO: Processing hook hook-sysconfig.py
174351 INFO: Processing hook hook-xml.py
174354 INFO: Processing hook hook-httplib.py
174355 INFO: Processing hook hook-pydoc.py
174360 INFO: Excluding import 'Tkinter'
174365 WARNING: From pydoc removing import Tkinter
174367 INFO: Processing hook hook-_tkinter.py
174746 INFO: checking Tree
174748 INFO: Building Tree because out00-Tree.toc is non existent
174749 INFO: Building Tree out00-Tree.toc
175266 INFO: checking Tree
175266 INFO: Building Tree because out01-Tree.toc is non existent
175266 INFO: Building Tree out01-Tree.toc
175345 INFO: Processing hook hook-matplotlib.backends.py
176546 INFO: Matplotlib backend "GTK": ignored
Gtk* backend requires pygtk to be installed.
177500 INFO: Matplotlib backend "GTKAgg": ignored
Gtk* backend requires pygtk to be installed.
178215 INFO: Matplotlib backend "GTKCairo": ignored
No module named gtk
179278 INFO: Matplotlib backend "MacOSX": ignored
cannot import name _macosx
180269 INFO: Matplotlib backend "Qt4Agg": ignored
Matplotlib qt-based backends require an external PyQt4, PyQt5,
or PySide package to be installed, but it was not found.
181282 INFO: Matplotlib backend "Qt5Agg": ignored
Matplotlib qt-based backends require an external PyQt4, PyQt5,
or PySide package to be installed, but it was not found.
182328 INFO: Matplotlib backend "TkAgg": added
183301 INFO: Matplotlib backend "WX": ignored
Matplotlib backend_wx and backend_wxagg require wxPython >=2.8.12
184281 INFO: Matplotlib backend "WXAgg": ignored
Matplotlib backend_wx and backend_wxagg require wxPython >=2.8.12
184906 INFO: Matplotlib backend "GTK3Cairo": ignored
Gtk3 backend requires pygobject to be installed.
185884 INFO: Matplotlib backend "GTK3Agg": ignored
Gtk3 backend requires pygobject to be installed.
186592 INFO: Matplotlib backend "WebAgg": ignored
Traceback (most recent call last):
File "<string>", line 12, in <module>
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_webagg.py", line 30, in <module>
raise RuntimeError("The WebAgg backend requires Tornado.")
RuntimeError: The WebAgg backend requires Tornado.
187286 INFO: Matplotlib backend "nbAgg": ignored
No module named tornado.ioloop
188268 INFO: Matplotlib backend "agg": added
188937 INFO: Matplotlib backend "cairo": ignored
Cairo backend requires that cairocffi or pycairo is installed.
189548 INFO: Matplotlib backend "emf": ignored
No module named backend_emf
190177 INFO: Matplotlib backend "gdk": ignored
No module named gobject
191144 INFO: Matplotlib backend "pdf": added
192591 INFO: Matplotlib backend "pgf": added
193523 INFO: Matplotlib backend "ps": added
194483 INFO: Matplotlib backend "svg": added
195419 INFO: Matplotlib backend "template": added
195825 INFO: Processing hook hook-matplotlib.py
196477 INFO: Processing hook hook-pkg_resources.py
196485 INFO: Processing hook hook-pytz.py
196694 INFO: Processing hook hook-pywintypes.py
197203 INFO: Processing hook hook-setuptools.py
197206 INFO: Processing hook hook-encodings.py
198177 INFO: Processing hook hook-win32com.py
198361 INFO: Processing hook hook-pythoncom.py
198950 INFO: checking Tree
198952 INFO: Building Tree because out02-Tree.toc is non existent
198953 INFO: Building Tree out02-Tree.toc
199026 INFO: Looking for ctypes DLLs
199108 INFO: Analyzing run-time hooks ...
199144 WARNING: Attempted to add Python module twice with different upper/lowercases: ConfigParser
199157 INFO: Including run-time hook 'pyi_rth__tkinter.py'
199161 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
199166 INFO: Including run-time hook 'pyi_rth_pkgres.py'
199180 INFO: Including run-time hook 'pyi_rth_mplconfig.py'
199184 INFO: Including run-time hook 'pyi_rth_mpldata.py'
199279 WARNING: Attempted to add Python module twice with different upper/lowercases: ConfigParser
199337 INFO: Looking for dynamic libraries
200154 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_ecff360cfb2594f3.manifest
200156 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_ed01d9e4fb230e88.manifest
200475 INFO: Searching for assembly x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.30729.6161_none ...
200476 INFO: Found manifest C:\WINDOWS\WinSxS\Manifests\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_4bf7e3e2bf9ada4c.manifest
200480 INFO: Searching for file mfc90.dll
200482 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_4bf7e3e2bf9ada4c\mfc90.dll
200483 INFO: Searching for file mfc90u.dll
200483 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_4bf7e3e2bf9ada4c\mfc90u.dll
200483 INFO: Searching for file mfcm90.dll
200483 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_4bf7e3e2bf9ada4c\mfcm90.dll
200485 INFO: Searching for file mfcm90u.dll
200486 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_4bf7e3e2bf9ada4c\mfcm90u.dll
200809 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_ecff360cfb2594f3.manifest
200812 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_ed01d9e4fb230e88.manifest
200815 INFO: Adding redirect Microsoft.VC90.MFC version (9, 0, 21022, 8) -> (9, 0, 30729, 6161)
201937 INFO: Looking for eggs
201937 INFO: Using Python library C:\WINDOWS\system32\python27.dll
201939 INFO: Found binding redirects:
[BindingRedirect(name=u'Microsoft.VC90.CRT', language=None, arch=u'x86', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 9177), publicKeyToken=u'1fc8b3b9a1e18e3b'), BindingRedirect(name=u'Microsoft.VC90.MFC', language=None, arch=u'x86', oldVersion=(9
, 0, 21022, 8), newVersion=(9, 0, 30729, 6161), publicKeyToken=u'1fc8b3b9a1e18e3b')]
202015 INFO: Warnings written to C:\Python27\Lib\site-packages\GUI_tempCtrl\build\plot\warnplot.txt
203518 INFO: checking PYZ
203518 INFO: Building PYZ because out00-PYZ.toc is non existent
203519 INFO: Building PYZ (ZlibArchive) C:\Python27\Lib\site-packages\GUI_tempCtrl\build\plot\out00-PYZ.pyz
206794 INFO: checking PKG
206795 INFO: Building PKG because out00-PKG.toc is non existent
206796 INFO: Building PKG (CArchive) out00-PKG.pkg
206868 INFO: Bootloader C:\Python27\lib\site-packages\pyinstaller-3.1.1-py2.7.egg\PyInstaller\bootloader\Windows-32bit\run.exe
206870 INFO: checking EXE
206871 INFO: Building EXE because out00-EXE.toc is non existent
206871 INFO: Building EXE from out00-EXE.toc
206893 INFO: Appending archive to EXE C:\Python27\Lib\site-packages\GUI_tempCtrl\build\plot\plot.exe
206940 INFO: checking COLLECT
206940 INFO: Building COLLECT because out00-COLLECT.toc is non existent
206942 INFO: Building COLLECT out00-COLLECT.toc
206993 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9177)
答案 0 :(得分:0)
我找到了解决方案。错误消息是'没有名为FileDialog 的模块',所以我import FileDialog
代码,它工作正常!