我想使用PyInstaller将简单的.py代码转换为.exe,该程序可以在python上正常工作,但是当我使用PyInstaller将其转换为.exe时,它返回错误:
ModuleNotFoundError: No module named numpy.core._dtype.ctypes
我尝试安装ctypes模块,但是发生了同样的错误。
如何解决此错误?
.py代码:
import numpy
input("Worked")
cmd输出:
C:\Users\enzo\Desktop\Compilando\dist\iaf>iaf.exe
Traceback (most recent call last):
File "iaf.py", line 1, in <module>
File "c:\users\enzo\appdata\local\programs\python\python37\lib\site-packages\P
yInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\numpy\__init__.py", line 151, in <module>
File "c:\users\enzo\appdata\local\programs\python\python37\lib\site-packages\P
yInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\numpy\ctypeslib.py", line 369, in <module>
File "site-packages\numpy\ctypeslib.py", line 358, in _get_typecodes
File "site-packages\numpy\ctypeslib.py", line 358, in <dictcomp>
ModuleNotFoundError: No module named 'numpy.core._dtype_ctypes'
[2872] Failed to execute script iaf
答案 0 :(得分:1)
在我添加到代码的开头之后:
import numpy.core._dtype_ctypes
我的代码有效
在KmolYuan上监视
答案 1 :(得分:0)
作为替代解决方案,您可以通过以下方式降级numpy软件包
python -m pip install numpy==1.15.0
,因为使用当前numpy版本(1.16.0)的pyinstaller似乎存在问题。