我想使用 pyinstaller 将包含“ from mayavi import mlab ”的python脚本转换为 .exe 文件。
Python脚本 Test1.py 仅包含一行代码: from mayavi import mlab
通过使用命令 pyinstaller Test1.py ,我可以将python脚本转换为.exe文件。但是,当我运行.exe文件时,收到以下错误消息
from mayavi import mlab
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\miniconda3\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\mayavi\mlab.py", line 16, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\miniconda3\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\mayavi\tools\camera.py", line 24, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\miniconda3\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\mayavi\tools\engine_manager.py", line 12, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\miniconda3\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\mayavi\preferences\api.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\miniconda3\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\mayavi\preferences\preference_manager.py", line 29, in <mo
dule>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\miniconda3\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\traitsui\api.py", line 36, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\miniconda3\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\traitsui\editors\__init__.py", line 23, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\miniconda3\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\traitsui\editors\api.py", line 24, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\programdata\miniconda3\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\traitsui\editors\code_editor.py", line 37, in <module>
File "site-packages\traitsui\editors\code_editor.py", line 49, in ToolkitEdito
rFactory
File "site-packages\traits\traits.py", line 655, in __call__
File "site-packages\traits\traits.py", line 1414, in Color
File "site-packages\traitsui\toolkit_traits.py", line 8, in ColorTrait
File "site-packages\traitsui\toolkit.py", line 109, in toolkit
File "site-packages\pyface\base_toolkit.py", line 281, in find_toolkit
File "site-packages\pyface\base_toolkit.py", line 209, in import_toolkit
RuntimeError: No traitsui.toolkits plugin found for toolkit null
[8520] Failed to execute script Test1
在下面,您可以找到我用pip安装的软件包:
Package Version
--------------- ------------------
altgraph 0.16.1
apptools 4.4.0
asn1crypto 0.24.0
certifi 2019.3.9
cffi 1.12.3
chardet 3.0.4
conda 4.6.14
configobj 5.0.6
cryptography 2.6.1
cycler 0.10.0
envisage 4.7.1
future 0.17.1
idna 2.8
kiwisolver 1.1.0
macholib 1.11
matplotlib 3.1.0
mayavi 4.6.2
menuinst 1.4.16
mkl-fft 1.0.12
mkl-random 1.0.2
numpy 1.11.3
pefile 2019.4.18
Pillow 6.0.0
pip 19.1.1
pycosat 0.6.3
pycparser 2.19
pyface 6.1.0
Pygments 2.4.0
PyInstaller 3.5.dev0+d74052489
pyOpenSSL 19.0.0
pyparsing 2.4.0
PySocks 1.7.0
python-dateutil 2.8.0
pywin32 223
pywin32-ctypes 0.2.0
QtPy 1.7.1
requests 2.21.0
ruamel-yaml 0.15.46
scipy 1.2.1
setuptools 41.0.1
shiboken2 5.12.3
sip 4.19.8
six 1.12.0
traits 5.1.1
traitsui 6.0.0
urllib3 1.24.2
vtk 8.1.2
wheel 0.33.4
win-inet-pton 1.1.0
wincertstore 0.2
wxPython 4.0.6
我看到了此link中发布的问题,但不了解其工作原理。我宁愿使用pyinstaller将python脚本转换成.exe文件。