为了账号安全,请及时绑定邮箱和手机立即绑定

Pyinstaller ImportError with scipy:

Pyinstaller ImportError with scipy:

慕的地6264312 2022-06-07 16:40:44
我有这个 Python 脚本,我想用 Pyinstaller 将其转换为 EXE 文件。这是我的规格文件:# -*- mode: python ; coding: utf-8 -*-# work-around for https://github.com/pyinstaller/pyinstaller/issues/4064import distutilsif distutils.distutils_path.endswith('__init__.py'):    distutils.distutils_path = os.path.dirname(distutils.distutils_path)block_cipher = Nonea = Analysis(['hello-world.py'],             pathex=['C:\\Users\\Testuser\\workspace\\hello-world'],             binaries=[],             datas=[ ('lib/*', '.') ],             hiddenimports=[               'distutils',               'scipy._lib.messagestream',               'sklearn.neighbors.typedefs',               'sklearn.neighbors.quad_tree',               'sklearn.tree',               'sklearn.tree._utils'             ],             hookspath=[],             runtime_hooks=[],             excludes=[],             win_no_prefer_redirects=False,             win_private_assemblies=False,             cipher=block_cipher,             noarchive=False)pyz = PYZ(a.pure, a.zipped_data,             cipher=block_cipher)exe = EXE(pyz,          a.scripts,          [],          exclude_binaries=True,          name='hello-world',          debug=False,          bootloader_ignore_signals=False,          strip=False,          upx=True,          console=True )coll = COLLECT(exe,               a.binaries,               a.zipfiles,               a.datas,               strip=False,               upx=True,               upx_exclude=[],               name='hello-world')但是在 Win 10 64 位虚拟机中运行时出现此错误:Traceback (most recent call last):  File "hello-world.py", line 11, in <module>  File "c:\users\testuser\workspace\hello-world\.venv\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_moduleEXE 在我构建它的机器上运行良好。将文件夹复制到 VM 中会导致上述错误。我不确定错误指的是哪个 DLL。我猜它与错误中的路径有关,因为c:\users\testuser\workspace\hello-worldVM 中不存在。我在这里缺少 Pyinstaller 选项吗?生成的 EXE 是否应该引用我的旧路径?
查看完整描述

1 回答

?
FFIVE

TA贡献1797条经验 获得超6个赞

这是因为我没有安装 MKL 版本的 Numpy 和 SciPy。


安装它们后,我将缺少的 DLL 文件添加到规范文件中:


datas=[

    ('lib/*', '.'),

    ('.venv/Lib/site-packages/numpy/DLLs/mkl_intel_thread.dll', '.'),

    ('.venv/Lib/site-packages/numpy/DLLs/mkl_core.dll', '.'),

    ('.venv/Lib/site-packages/numpy/DLLs/mkl_def.dll', '.'),

    ('.venv/Lib/site-packages/numpy/DLLs/libiomp5md.dll', '.')

],

现在它可以在我的虚拟机中运行。


希望这对某人有帮助!


查看完整回答
反对 回复 2022-06-07
  • 1 回答
  • 0 关注
  • 126 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号