【发布时间】:2020-12-27 20:31:29
【问题描述】:
我很难将我的 python 代码转换为 exe。在我使用 pyinstaller 将我的代码转换为 exe 后,它给了我一个错误,当我运行它时它缺少导入。这是完整的日志:
Traceback (most recent call last):
File "new.py", line 1, in <module>
File "/Users/name/opt/anaconda3/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "nsepython/__init__.py", line 1, in <module>
File "/Users/name/opt/anaconda3/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "nsepython/rahu.py", line 6, in <module>
File "/Users/name/opt/anaconda3/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pandas/__init__.py", line 179, in <module>
File "/Users/name/opt/anaconda3/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pandas/testing.py", line 5, in <module>
File "/Users/name/opt/anaconda3/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pandas/_testing.py", line 27, in <module>
File "pandas/_libs/testing.pyx", line 1, in init pandas._libs.testing
ModuleNotFoundError: No module named 'cmath'
[74486] Failed to execute script new
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
我要转换的文件的名称是 new.py,它依赖于显然找不到名为 cmath 的模块的 pandas。我该如何解决?无论如何我可以构建一个exe吗?
【问题讨论】:
-
cmath是一个 Python 标准库模块,用于解复杂算术。所以它总是可用的。可能是pyinstaller无法确定需要它,因此没有将其包含在.exe中。查看pyinstaller文档,了解您如何在.spec文件中暗示应该包含它。 -
啊,是的,我想通了,你是对的@BoarGules
标签: python pandas pyinstaller