IPython 模块导入错误:/usr/bin/ld: 找不到 -lpython2.7.collect2: ld 返回 1 个退出状态 [英] IPython module import error: /usr/bin/ld: cannot find -lpython2.7. collect2: ld returned 1 exit status

查看:60
本文介绍了IPython 模块导入错误:/usr/bin/ld: 找不到 -lpython2.7.collect2: ld 返回 1 个退出状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器上使用 Python 模块 Theano.它没有预先安装在那里,所以我将它与服务器上没有的其他一些模块一起安装在我的主文件夹中.在 IPython 中导入 theano"时出现以下错误.

I'm using the Python module Theano on a server. It is not pre-installed on there so I installed it in my home folder along with some other modules that weren't on the server. I get the following error when I "import theano" in IPython.

Problem occurred during compilation with the command line below:
g++ -shared -g -march=core2 -mcx16 -msahf -maes -mpclmul -mpopcnt -msse4.2 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=12288 -mtune=generic -D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D NPY_ARRAY_ENSURECOPY=NPY_ENSURECOPY -D NPY_ARRAY_ALIGNED=NPY_ALIGNED -D NPY_ARRAY_WRITEABLE=NPY_WRITEABLE -D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL -D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS -D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS -m64 -fPIC -I/apps/libs/python/2.7.3/lib/python2.7/site-packages/numpy/core/include -I/home/ext_sxc/include/python2.7 -o /home/ext_sxc/.theano/compiledir_Linux-2.6.32-431.1.2.0.1.el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-2.7.3-64/lazylinker_ext/lazylinker_ext.so /home/ext_sxc/.theano/compiledir_Linux-2.6.32-431.1.2.0.1.el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-2.7.3-64/lazylinker_ext/mod.cpp -L/home/ext_sxc/lib -lpython2.7
/usr/bin/ld: cannot find -lpython2.7
collect2: ld returned 1 exit status

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-1-3397704bd624> in <module>()
----> 1 import theano

/home/ext_sxc/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/__init__.pyc in <module>()
     53     object2, utils
     54
---> 55 from theano.compile import \
     56     SymbolicInput, In, \
     57     SymbolicOutput, Out, \

/home/ext_sxc/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/compile/__init__.py in <module>()
      4         ViewOp, view_op, register_view_op_c_code)
      5
----> 6 from theano.compile.function_module import *
      7
      8 from theano.compile.mode import *

/home/ext_sxc/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/compile/function_module.py in <module>()
     16 from theano import gof
     17 from theano.gof.python25 import partial
---> 18 import theano.compile.mode
     19 from theano.compile.io import In, SymbolicInput, SymbolicInputKit, SymbolicOutput
     20 from theano.compile.ops import deep_copy_op, view_op

/home/ext_sxc/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/compile/mode.py in <module>()
      9 import  theano
     10 from theano import gof
---> 11 import theano.gof.vm
     12 from theano.configparser import config, AddConfigVar, StrParam
     13 from theano.compile.ops import register_view_op_c_code, _output_guard

/home/ext_sxc/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/gof/vm.py in <module>()
    514
    515 try:
--> 516     import lazylinker_c
    517
    518     class CVM(lazylinker_c.CLazyLinker, VM):

/home/ext_sxc/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/gof/lazylinker_c.py in <module>()
     84             args = cmodule.GCC_compiler.compile_args()
     85             cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
---> 86                                              preargs=args)
     87             # Save version into the __init__.py file.
     88             init_py = os.path.join(loc, '__init__.py')

/home/ext_sxc/lib/python2.7/site-packages/Theano-0.6.0-py2.7.egg/theano/gof/cmodule.pyc in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module)
   1969             # difficult to read.
   1970             raise Exception('Compilation failed (return status=%s): %s' %
-> 1971                             (status, compile_stderr.replace('\n', '. ')))
   1972         elif config.cmodule.compilation_warning and compile_stderr:
   1973             # Print errors just below the command line.

Exception: Compilation failed (return status=1): /usr/bin/ld: cannot find -lpython2.7. collect2: ld returned 1 exit status.

如何修复上述错误?

另一件事是,每当我在服务器上运行 Python 作业时,我都会先做

Another thing is that whenever I run a Python job on the server, I first do

$ module load libs/python/2.7.3

在执行我的 Python 脚本之前,服务器的/usr/lib64 文件夹中有 libpython2.6.so.我认为这与问题有关.

before executing my Python script and the server has libpython2.6.so in its /usr/lib64 folder. I think this is related to the problem.

推荐答案

您的 python 安装不完整.当你这样做时:

Your python installation is incomplete. When you do:

module load libs/python/2.7.3

信息被添加到你的环境变量中,让你使用 python 2.7.3.但是这个版本不包含python的开发头文件(Theano需要这个).或者它没有在您的环境中放置正确的路径.

information is added to your environment variables to make you use python 2.7.3. But this version doesn't include the development header of python (Theano needs this). Or it doesn't put the right path in your environment.

要调试它,请在运行module load libs/python/2.7.3"之前和之后运行它以比较模块加载的作用:

To debug this, run this before and after running "module load libs/python/2.7.3" to compare what module load does:

env &> BEFORE.txt
module load libs/python/2.7.3
env &> AFTER.txt
diff BEFORE.txt AFTER.txt

然后检查添加到环境变量的路径并查看这些目录.它应该修改了 LD_LIBRARY_PATH 变量,但它应该对 LIBRARY_PATH 进行了相同的修改.如果没有,请自行修改并告诉您的系统管理员.

Then check the paths added to your env variables and look in those directories. It should have modified the LD_LIBRARY_PATH variable, but it should have done the same modification to LIBRARY_PATH. If it doesn't, do that modification yourself and tell your system admin about this.

这将解决您的问题.

否则,请使用操作系统中的 python 2.6,可能包含开发版本.

Otherwise, use the python 2.6 from the OS, maybe in include the development version.

否则,通过模块检查是否有其他python版本可用.

Otherwise, check if other python versions are available via module.

最后,联系您的系统管理员添加python的开发和共享版本或自行安装:

Lastly, contact your system admin to add the development and shared version of python or install it yourself:

wget -c http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
tar -jxf Python-2.7.6.tar.bz2 
cd Python-2.7.6
./configure --prefix=~/python2.7.6 --enable-shared
make
make install

这篇关于IPython 模块导入错误:/usr/bin/ld: 找不到 -lpython2.7.collect2: ld 返回 1 个退出状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆