Python 启动Exe时FileNotFoundError

Python 启动Exe时FileNotFoundError,python,tkinter,exe,Python,Tkinter,Exe,我用Tkinter创建了一个GUI,其中包括工具提示。为了创建工具提示,我使用了这个包 当我使用Pyinstaller从脚本创建一个可执行文件并启动该可执行文件时,我得到一个FileNotFoundError: 我使用AnacondaJupyter笔记本,并在一个环境中安装了所有Python包(包括Pmw)。你们中有谁知道我如何修复这个错误吗 编辑2: 我想我找到了错误的原因。Pyinstaller未包含/加载Pmw包 编辑1: 仅当直接执行主Python文件时,才从exe引发此文件NotFo

我用Tkinter创建了一个GUI,其中包括工具提示。为了创建工具提示,我使用了这个包

当我使用Pyinstaller从脚本创建一个可执行文件并启动该可执行文件时,我得到一个FileNotFoundError:

我使用AnacondaJupyter笔记本,并在一个环境中安装了所有Python包(包括Pmw)。你们中有谁知道我如何修复这个错误吗

编辑2: 我想我找到了错误的原因。Pyinstaller未包含/加载Pmw包

编辑1: 仅当直接执行主Python文件时,才从exe引发此文件NotFounder

创建exe时的详细信息:

(base) C:\Users\....\Desktop\Code>pyinstaller --onefile test.py
207 INFO: PyInstaller: 3.6
208 INFO: Python: 3.7.4 (conda)
209 INFO: Platform: Windows-10-10.0.17763-SP0
225 INFO: wrote C:\Users\....\Desktop\Code\test.spec
232 INFO: UPX is not available.
236 INFO: Extending PYTHONPATH with paths
['C:\\Users\\....\\Desktop\\Code', 'C:\\Users\\....\\Desktop\\Code']
237 INFO: checking Analysis
238 INFO: Building Analysis because Analysis-00.toc is non existent
238 INFO: Initializing module dependency graph...
262 INFO: Caching module graph hooks...
288 INFO: Analyzing base_library.zip ...
12229 INFO: Caching module dependency graph...
12637 INFO: running Analysis Analysis-00.toc
12685 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\....\appdata\local\continuum\anaconda3\python.exe
14030 INFO: Analyzing C:\Users\....\Desktop\Code\test.py
16703 INFO: Processing pre-find module path hook   distutils
16709 INFO: distutils: retargeting to non-venv dir 'c:\\users\\....\\appdata\\local\\continuum\\anaconda3\\lib'
20840 INFO: Processing pre-find module path hook   site
20845 INFO: site: retargeting to fake-dir 'c:\\users\\....\\appdata\\local\\continuum\\anaconda3\\lib\\site-packages\\PyInstaller\\fake-modules'
27447 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
48638 INFO: Processing pre-safe import module hook   six.moves
65399 INFO: Processing pre-safe import module hook   urllib3.packages.six.moves
122663 INFO: Processing module hooks...
122663 INFO: Loading module hook "hook-babel.py"...
122929 INFO: Loading module hook "hook-certifi.py"...
122936 INFO: Loading module hook "hook-Crypto.py"...
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'Crypto.Math'
123126 INFO: Loading module hook "hook-cryptography.py"...
124300 INFO: Loading module hook "hook-distutils.py"...
124306 INFO: Loading module hook "hook-docutils.py"...
129334 INFO: Loading module hook "hook-encodings.py"...
129546 INFO: Loading module hook "hook-importlib_metadata.py"...
129558 INFO: Loading module hook "hook-IPython.py"...
132300 INFO: Excluding import 'tkinter'
132310 INFO:   Removing import of tkinter from module IPython.lib.clipboard
132312 INFO: Excluding import 'gtk'
132323 INFO: Excluding import 'matplotlib'
132335 INFO:   Removing import of matplotlib._pylab_helpers from module IPython.core.pylabtools
132336 INFO:   Removing import of matplotlib.figure from module IPython.core.pylabtools
132337 INFO:   Removing import of matplotlib from module IPython.core.pylabtools
132338 INFO:   Removing import of matplotlib.pyplot from module IPython.core.pylabtools
132343 INFO: Excluding import 'PyQt4'
132355 INFO:   Removing import of PyQt4 from module IPython.external.qt_loaders
132357 INFO: Excluding import 'PySide'
132370 INFO:   Removing import of PySide from module IPython.external.qt_loaders
132372 INFO: Excluding import 'PyQt5'
132381 INFO:   Removing import of PyQt5.QtSvg from module IPython.external.qt_loaders
132381 INFO:   Removing import of PyQt5.QtWidgets from module IPython.external.qt_loaders
132383 INFO:   Removing import of PyQt5.QtCore from module IPython.external.qt_loaders
132384 INFO:   Removing import of PyQt5.QtGui from module IPython.external.qt_loaders
132385 INFO:   Removing import of PyQt5 from module IPython.external.qt_loaders
132388 INFO: Loading module hook "hook-jedi.py"...
132886 INFO: Loading module hook "hook-jinja2.py"...
132995 INFO: Loading module hook "hook-jsonschema.py"...
133011 INFO: Loading module hook "hook-lib2to3.py"...
133023 INFO: Loading module hook "hook-matplotlib.backends.py"...
136628 INFO:   Matplotlib backend "GTK3Agg": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
137407 INFO:   Matplotlib backend "GTK3Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
138701 INFO:   Matplotlib backend "MacOSX": ignored
    cannot import name '_macosx' from 'matplotlib.backends' (c:\users\....\appdata\local\continuum\anaconda3\lib\site-packages\matplotlib\backends\__init__.py)
141186 INFO:   Matplotlib backend "nbAgg": added
143339 INFO:   Matplotlib backend "Qt4Agg": added
144384 INFO:   Matplotlib backend "Qt4Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
145837 INFO:   Matplotlib backend "Qt5Agg": added
146807 INFO:   Matplotlib backend "Qt5Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
148102 INFO:   Matplotlib backend "TkAgg": added
149156 INFO:   Matplotlib backend "TkCairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
150342 INFO:   Matplotlib backend "WebAgg": added
151462 INFO:   Matplotlib backend "WX": ignored
    No module named 'wx'
152388 INFO:   Matplotlib backend "WXAgg": ignored
    No module named 'wx'
153343 INFO:   Matplotlib backend "WXCairo": ignored
    No module named 'wx'
154339 INFO:   Matplotlib backend "agg": added
155198 INFO:   Matplotlib backend "cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
156241 INFO:   Matplotlib backend "pdf": added
157287 INFO:   Matplotlib backend "pgf": added
158123 INFO:   Matplotlib backend "ps": added
158968 INFO:   Matplotlib backend "svg": added
160022 INFO:   Matplotlib backend "template": added
160810 INFO: Loading module hook "hook-matplotlib.py"...
161561 INFO: Loading module hook "hook-nbconvert.py"...
161610 INFO: Loading module hook "hook-nbformat.py"...
161630 INFO: Loading module hook "hook-notebook.py"...
166746 INFO: Loading module hook "hook-numpy.core.py"...
166991 INFO: MKL libraries found when importing numpy. Adding MKL to binaries
167001 INFO: Loading module hook "hook-numpy.py"...
167006 INFO: Loading module hook "hook-PIL.Image.py"...
168235 INFO: Loading module hook "hook-PIL.py"...
168246 INFO: Excluding import 'tkinter'
168251 INFO:   Removing import of tkinter from module PIL.ImageTk
168255 INFO: Import to be excluded not found: 'FixTk'
168256 INFO: Excluding import 'PyQt4'
168263 INFO:   Removing import of PyQt4 from module PIL.ImageQt
168264 INFO: Excluding import 'PySide'
168271 INFO:   Removing import of PySide from module PIL.ImageQt
168273 INFO: Excluding import 'PyQt5'
168279 INFO:   Removing import of PyQt5.QtCore from module PIL.ImageQt
168279 INFO:   Removing import of PyQt5.QtGui from module PIL.ImageQt
168281 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
168293 INFO: Excluding import 'tkinter'
168298 INFO: Import to be excluded not found: 'FixTk'
168298 INFO: Loading module hook "hook-pkg_resources.py"...
169883 INFO: Processing pre-safe import module hook   win32com
170754 INFO: Excluding import '__main__'
170759 INFO:   Removing import of __main__ from module pkg_resources
170759 INFO: Loading module hook "hook-pycparser.py"...
170764 INFO: Loading module hook "hook-pydoc.py"...
170770 INFO: Loading module hook "hook-pygments.py"...
175041 INFO: Loading module hook "hook-PyQt5.py"...
176374 WARNING: Hidden import "PyQt5.sip" not found!
176374 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
176799 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
177238 INFO: Loading module hook "hook-PyQt5.QtSvg.py"...
178125 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
178871 INFO: Loading module hook "hook-pytest.py"...
181453 INFO: Loading module hook "hook-pythoncom.py"...
182802 INFO: Loading module hook "hook-pytz.py"...
183007 INFO: Loading module hook "hook-pywintypes.py"...
184144 INFO: Loading module hook "hook-scipy.linalg.py"...
184149 INFO: Loading module hook "hook-scipy.py"...
184156 INFO: Loading module hook "hook-scipy.sparse.csgraph.py"...
184170 INFO: Loading module hook "hook-scipy.special._ellip_harm_2.py"...
184174 INFO: Loading module hook "hook-scipy.special._ufuncs.py"...
184179 INFO: Loading module hook "hook-setuptools.py"...
186259 INFO: Loading module hook "hook-sphinx.py"...
200804 INFO: Loading module hook "hook-sqlite3.py"...
201025 INFO: Loading module hook "hook-sysconfig.py"...
201030 INFO: Loading module hook "hook-win32com.py"...
202494 INFO: Loading module hook "hook-xml.dom.domreg.py"...
202499 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
202504 INFO: Loading module hook "hook-xml.py"...
202511 INFO: Loading module hook "hook-zmq.py"...
207967 INFO: Loading module hook "hook-_tkinter.py"...
208496 INFO: checking Tree
208496 INFO: Building Tree because Tree-00.toc is non existent
208497 INFO: Building Tree Tree-00.toc
208735 INFO: checking Tree
208735 INFO: Building Tree because Tree-01.toc is non existent
208736 INFO: Building Tree Tree-01.toc
208775 INFO: Loading module hook "hook-gevent.py"...
209451 INFO: Determining a mapping of distributions to packages...
370757 WARNING: Unable to find package for requirement greenlet from package gevent.
370757 INFO: Packages required by gevent:
['cffi']
375108 INFO: Loading module hook "hook-lxml.etree.py"...
375550 INFO: Looking for ctypes DLLs
375901 INFO: Analyzing run-time hooks ...
375937 INFO: Including run-time hook 'pyi_rth_pkgres.py'
375946 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
375957 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
375970 INFO: Including run-time hook 'pyi_rth_traitlets.py'
375978 INFO: Including run-time hook 'pyi_rth_certifi.py'
375986 INFO: Including run-time hook 'pyi_rth_pyqt5.py'
375995 INFO: Including run-time hook 'pyi_rth_mplconfig.py'
376002 INFO: Including run-time hook 'pyi_rth_mpldata.py'
376010 INFO: Including run-time hook 'pyi_rth__tkinter.py'
376131 INFO: Looking for dynamic libraries
377279 WARNING: lib not found: msmpi.dll dependency of c:\users\....\appdata\local\continuum\anaconda3\Library\bin\mkl_blacs_msmpi_ilp64.dll
377306 WARNING: lib not found: impi.dll dependency of c:\users\....\appdata\local\continuum\anaconda3\Library\bin\mkl_blacs_intelmpi_lp64.dll
377839 WARNING: lib not found: msmpi.dll dependency of c:\users\....\appdata\local\continuum\anaconda3\Library\bin\mkl_blacs_msmpi_lp64.dll
379576 WARNING: lib not found: pgc14.dll dependency of c:\users\....\appdata\local\continuum\anaconda3\Library\bin\mkl_pgi_thread.dll
379578 WARNING: lib not found: pgf90rtl.dll dependency of c:\users\....\appdata\local\continuum\anaconda3\Library\bin\mkl_pgi_thread.dll
379581 WARNING: lib not found: pgf90.dll dependency of c:\users\....\appdata\local\continuum\anaconda3\Library\bin\mkl_pgi_thread.dll
381124 WARNING: lib not found: impi.dll dependency of c:\users\....\appdata\local\continuum\anaconda3\Library\bin\mkl_blacs_intelmpi_ilp64.dll
381172 WARNING: lib not found: mpich2mpi.dll dependency of c:\users\....\appdata\local\continuum\anaconda3\Library\bin\mkl_blacs_mpich2_ilp64.dll
381279 WARNING: lib not found: mpich2mpi.dll dependency of c:\users\....\appdata\local\continuum\anaconda3\Library\bin\mkl_blacs_mpich2_lp64.dll
387553 INFO: Looking for eggs
387554 INFO: Using Python library c:\users\....\appdata\local\continuum\anaconda3\python37.dll
387555 INFO: Found binding redirects:
[]
387632 INFO: Warnings written to C:\Users\....\Desktop\Code\build\test\warn-test.txt
388866 INFO: Graph cross-reference written to C:\Users\....\Desktop\Code\build\test\xref-test.html
389262 INFO: checking PYZ
389262 INFO: Building PYZ because PYZ-00.toc is non existent
389265 INFO: Building PYZ (ZlibArchive) C:\Users\....\Desktop\Code\build\test\PYZ-00.pyz
395965 INFO: Building PYZ (ZlibArchive) C:\Users\....\Desktop\Code\build\test\PYZ-00.pyz completed successfully.
396257 INFO: checking PKG
396257 INFO: Building PKG because PKG-00.toc is non existent
396258 INFO: Building PKG (CArchive) PKG-00.pkg
575871 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
576232 INFO: Bootloader c:\users\....\appdata\local\continuum\anaconda3\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
576233 INFO: checking EXE
576234 INFO: Building EXE because EXE-00.toc is non existent
576236 INFO: Building EXE from EXE-00.toc
576238 INFO: Appending archive to EXE C:\Users\....\Desktop\Code\dist\test.exe
576660 INFO: Building EXE from EXE-00.toc completed successfully.
(基本)C:\Users\..\Desktop\code>pyinstaller--onefile test.py
207信息:PyInstaller:3.6
208信息:Python:3.7.4(康达)
209信息:平台:Windows-10-10.0.17763-SP0
225信息:编写了C:\Users\..\Desktop\Code\test.spec
232信息:UPX不可用。
236信息:使用路径扩展PYTHONPATH
['C:\\Users\\..\\Desktop\\Code','C:\\Users\\..\\Desktop\\Code']
237信息:检查分析
238信息:构建分析,因为Analysis-00.toc不存在
238信息:正在初始化模块依赖关系图。。。
262信息:缓存模块图形挂钩。。。
288信息:正在分析base_library.zip。。。
12229信息:缓存模块依赖关系图。。。
12637信息:运行分析-00.toc
12685信息:将Microsoft.Windows.Common-Controls添加到最终可执行文件的相关程序集
c:\users\..\appdata\local\continuum\anaconda3\python.exe所需
14030信息:正在分析C:\Users\..\Desktop\Code\test.py
16703信息:处理预查找模块路径挂钩区
16709信息:distutils:重定目标到非venv目录'c:\\users\\..\\appdata\\local\\continuum\\anaconda3\\lib'
20840信息:正在处理预查找模块路径挂钩站点
20845信息:站点:重新定位到伪目录'c:\\users\\..\\appdata\\local\\continuum\\anaconda3\\lib\\site packages\\PyInstaller\\fake Module'
27447信息:处理预安全导入模块hook setuptools.extern.six.moves
48638信息:正在处理预安全导入模块hook six.moves
65399信息:正在处理预安全导入模块挂钩urllib3.packages.six.moves
122663信息:处理模块挂钩。。。
122663信息:加载模块挂钩“hook babel.py”。。。
122929信息:加载模块挂钩“hook certifi.py”。。。
122936信息:加载模块挂钩“hook Crypto.py”。。。
回溯(最近一次呼叫最后一次):
文件“”,第2行,在
ModuleNotFoundError:没有名为“Crypto.Math”的模块
123126信息:加载模块钩子“hook cryptography.py”。。。
124300信息:加载模块挂钩“hook distutils.py”。。。
124306信息:加载模块挂钩“hook docutils.py”。。。
129334信息:加载模块hook“hook encodings.py”。。。
129546信息:加载模块钩子“hook-importlib_metadata.py”。。。
129558信息:加载模块挂钩“hook IPython.py”。。。
132300信息:不包括导入“tkinter”
132310信息:正在从模块IPython.lib.clipboard中删除tkinter的导入
132312信息:不包括进口“gtk”
132323信息:不包括导入“matplotlib”
132335信息:正在从模块IPython.core.pylabtools中删除matplotlib.\u pylab\u帮助程序的导入
132336信息:正在从模块IPython.core.pylabtools中删除matplotlib.figure的导入
132337信息:正在从模块IPython.core.pylabtools中删除matplotlib的导入
132338信息:正在从模块IPython.core.pylabtools中删除matplotlib.pyplot的导入
132343信息:不包括导入“PyQt4”
132355信息:正在从模块IPython.external.qt_加载程序中删除PyQt4的导入
132357信息:不包括导入“PySide”
132370信息:正在从模块IPython.external.qt_加载程序中删除PySide的导入
132372信息:不包括导入“PyQt5”
132381信息:正在从模块IPython.external.qt_加载程序中删除PyQt5.QtSvg的导入
132381信息:正在从模块IPython.external.qt_加载程序中删除PyQt5.qtwidget的导入
132383信息:正在从模块IPython.external.qt_加载程序中删除PyQt5.QtCore的导入
132384信息:正在从模块IPython.external.qt_加载程序中删除PyQt5.QtGui的导入
132385信息:正在从模块IPython.external.qt_加载程序中删除PyQt5的导入
132388信息:加载模块挂钩“hook jedi.py”。。。
132886信息:加载模块挂钩“hook-jinja2.py”。。。
132995信息:加载模块挂钩“hook jsonschema.py”。。。
133011信息:加载模块挂钩“hook-lib2to3.py”。。。
133023信息:加载模块钩子“hook matplotlib.backends.py”。。。
136628信息:Matplotlib后端“GTK3Agg”:已忽略
cairo后端要求安装pycairo>=1.11.0或CairoCffi
137407信息:Matplotlib后端“GTK3Cairo”:已忽略
cairo后端要求安装pycairo>=1.11.0或CairoCffi
138701信息:Matplotlib后端“MacOSX”:已忽略
无法从“matplotlib.backends”(c:\users\..\appdata\local\continuum\anaconda3\lib\site packages\matplotlib\backends\\uu init\uuuuuuuuuuux.py)导入名称“\u macosx”
141186信息:Matplotlib后端“nbAgg”:已添加
143339信息:Matplotlib后端“Qt4Agg”:已添加
144384信息:Matplotlib后端“Qt4Cairo”:已忽略
cairo后端要求安装pycairo>=1.11.0或CairoCffi
145837信息:Matplotlib后端“Qt5Agg”:已添加
146807信息:Matplotlib后端“Qt5Cairo”:已忽略
cairo后端要求安装pycairo>=1.11.0或CairoCffi
148102信息:Matplotlib后端“TkAgg”:已添加
149156信息:Matplotlib后端“TkCairo”:已忽略
cairo后端要求安装pycairo>=1.11.0或CairoCffi
150342信息:Matplotlib后端“WebAgg”:已添加
151462信息:Matplotlib后端“WX”:已忽略
没有名为“wx”的模块
152388信息:Matplotlib后端“WXAgg”:已忽略
没有名为“wx”的模块
153343信息:Matplotlib后端“WXCairo”:已忽略
没有名为“wx”的模块
154339信息:Matplotlib后端“agg”:已添加
155198信息:Matplotlib后端“cairo”:已忽略
cairo后端要求安装pycairo>=1.11.0或CairoCffi
156241信息:Matplotlib后端“pdf”:已添加
157287信息:Matplotlib bac