python - pyinstaller错误: cannot find scipy (No module named _ufuncs_cxx)

标签 python scipy enthought pyinstaller canopy

我正在使用 pyinstaller 将 python 脚本转换为 Ubuntu (14.04) 中的二进制文件。我使用 Canopy (Enthought) 来管理所有 python 库。

该代码使用了 networkx、numpy 和 scipy。这是我的规范文件:

# -*- mode: python -*-
a = Analysis(['main_test.py'],
             pathex=['/home/sean/Desktop/prog',],
             hiddenimports=[],
             hookspath=None,
             runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='main_test',
          debug=False,
          strip=None,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=None,
               upx=True,
               name='main_test')

起初我得到错误:

ImportError: libmkl_gf.so: cannot open shared object file: 
    No such file or directory

然后我找到了.so库

/home/sean/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib

我手动将几个 .so 文件复制到 dist 目录中。

但是,我得到了另一个错误:

  File "/home/sean/Enthought/Canopy_32bit/User/lib/python2.7/site-
        packages/PyInstaller/loader/pyi_importers.py", line 409, in load_module
        module = imp.load_module(fullname, fp, filename, self._c_ext_tuple)
  File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs
        (scipy/special/_ufuncs.c:21824)
ImportError: No module named _ufuncs_cxx

如何修复此错误?我应该如何修改规范文件以添加这些库和模块?

编辑:

我找到了解决方案。我现在的问题是:如何修改规范文件以添加 .so 库?现在我必须手动将一些 .so 文件复制到 dist 目录...

编辑2

事实证明,我必须将它添加到COLLECT:

a.binaries + ["libmkl_gf.so" , 
  "/home/sean/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib/libmkl_gf.so", 
  "binaries"]

有什么简单的方法可以找到隐藏的导入或库吗?

谢谢

最佳答案

我刚从解决问题中走出来。我必须使用 --hidden-import 标志指定缺少的模块。其中有很多缺失,但我注意到其中大部分来自 scipy.integrate。所以我指定:

pyinstaller --hidden-import=scipy.integrate --hidden-import=scipy.integrate.quadpack --hidden-import=scipy.integrate._vode bla bla bla bla -F --windowed myscript.py

痛苦,但有效

关于python - pyinstaller错误: cannot find scipy (No module named _ufuncs_cxx),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24472683/

相关文章:

python - Pandas DataFrame 删除 groupby 中的行

python-3.x - 使用整数输入的曲线拟合 Python 3.3

python - 在 Python 中使用兰伯特函数时的 NaN 值 - 在 Enthought Canopy 中

python - 如何用 Python 减去列表中的所有项目?

python - Sklearn GMM 给出偏移的高斯峰

javascript - 静态网页和共享同一 TLD 的谷歌应用引擎服务器之间的 AJAX

python - 如何在 Python 中进行非线性复根查找

python - 为什么我需要 "fftshift"DFT 的乘积来恢复卷积乘积

python - 使用不带 GUI 的 Canopy

python - Enthought + PyCharm - 无法再显示绘图