简体   繁体   English

pyinstaller错误:找不到scipy(没有名为_ufuncs_cxx的模块)

[英]pyinstaller error: cannot find scipy (No module named _ufuncs_cxx)

I am using pyinstaller to convert python script into a binary in Ubuntu (14.04). 我正在使用pyinstaller将python脚本转换为Ubuntu(14.04)中的二进制文件。 I use Canopy (Enthought) to manage all python libraries. 我使用Canopy(Enthought)管理所有python库。

The code uses networkx, numpy, and scipy. 该代码使用networkx,numpy和scipy。 Here is my spec file: 这是我的规格文件:

# -*- 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')

At first I got the error: 起初我得到了错误:

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

Then I found the .so library in 然后我在

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

I manually copied several .so files into the dist direcotry. 我手动将几个.so文件复制到dist目录中。

However, I got another error: 但是,我得到另一个错误:

  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

How do I fix this error? 如何解决此错误? And how should I modify the spec file to add those libraries and modules? 我应该如何修改规格文件以添加这些库和模块?

Edit: 编辑:

I found the solutuion. 我找到了解决办法。 My question is now: How can I modify the spec file to add the .so libraies? 现在的问题是:如何修改规格文件以添加.so库? Now I have to mannually copy a number of .so files to the dist directory... 现在,我必须手动将多个.so文件复制到dist目录...

Edit2 EDIT2

It turns out that I have to add it to COLLECT : 原来,我必须将其添加到COLLECT

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

Is there any easy way to find the hidden imports or libraries? 有什么简单的方法可以找到隐藏的导入或库?

Thanks 谢谢

I just came out from solving the problem. 我刚从解决问题中脱颖而出。 I had to specify the missing modules with the --hidden-import flag. 我必须使用--hidden-import标志指定缺少的模块。 There were a lot of them missing, but I noticed most of them were from scipy.integrate. 他们很多失踪了,但我注意到其中大多数来自scipy.integrate。 So I specified: 所以我指定:

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

Painful, but worked 很痛苦,但是很努力

Do you want to try adding the library paths into LD_LIBRARY_PATH? 您是否要尝试将库路径添加到LD_LIBRARY_PATH? something like, 就像是,

export LD_LIBRARY_PATH=/home/sean/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib 导出LD_LIBRARY_PATH = / home / sean / Canopy / appdata / canopy-1.3.0.1715.rh5-x86 / lib

or 要么

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/sean/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib (if already set up by admin) so that at run time all the .so in that folder won't give you linking error... 导出LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/home/sean/Canopy/appdata/canopy-1.3.0.1715.rh5-x86/lib(如果已由admin设置),以便在运行时该文件夹中的所有.so都不会给出您链接错误...

Oh I got what you mean, 哦,我明白你的意思,

import sys 导入系统

sys.path.append('your_lib_path') sys.path.append( 'your_lib_path')

This should work. 这应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM