Python导入错误:无法打开.so文件(没有这样的文件或目录)

时间:2017-07-21 19:54:53

标签: python bash ubuntu anaconda .so

我正在尝试使用费米科学工具(FST)和3ML(数据分析环境)进行一些天文分析。我知道我要激活FST,然后激活3ML虚拟环境;当我这样做时,一些问题开始出现;也就是说,有一些python无法识别的.so文件。我知道它与我的LD_LIBRARY_PATH环境变量有关,但我看不清楚是什么。有很多人有类似的问题,(Why can't Python find shared objects that are in directories in sys.path?),但他们的解决方案并没有解决我的问题。在ubuntu 16上的bash终端工作。

当我激活两个包时,我的LD_LIBRARY_PATH变量从空变为

'/home/max/anaconda2/3ML_env/FST/Fermi1/lib'

然而,当我进入python并开始使用3ML时,我收到以下错误

>>> from threeML import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/max/anaconda2/3ML_env/lib/python2.7/site-packages/threeML         /__init__.py", line 6, in <module>
 from .io.serialization import *
File "/home/max/anaconda2/3ML_env/lib/python2.7/site-packages/threeML/io/serialization.py", line 1, in <module>
from threeML.classicMLE.joint_likelihood import JointLikelihood
File "/home/max/anaconda2/3ML_env/lib/python2.7/site-packages/threeML/classicMLE/joint_likelihood.py", line 1, in <module>
import collections
File "/home/max/anaconda2/lib/python2.7/collections.py", line 21, in <module>
from operator import itemgetter as _itemgetter, eq as _eq
ImportError: /home/max/anaconda2/3ML_env/lib/python2.7/lib-dynload/operator.so: undefined symbol: _PyUnicodeUCS4_AsDefaultEncodedString

但是,如果我再次将LD_LIBRARY_PATH更改为空,我可以运行3ML代码没问题,直到我进一步深入到我的工作中,我才能得到错误:

LAT = FermipyLike("LAT", config)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/max/anaconda2/3ML_env/lib/python2.7/site-packages/threeML/plugins/FermipyLike.py", line 209, in __new__
_expensive_imports_hook()
File "/home/max/anaconda2/3ML_env/lib/python2.7/site-packages/threeML/plugins/FermipyLike.py", line 190, in _expensive_imports_hook
from fermipy.gtanalysis import GTAnalysis
File "/home/max/anaconda2/3ML_env/lib/python2.7/site-packages/fermipy/gtanalysis.py", line 20, in <module>
import fermipy.gtutils as gtutils
File "/home/max/anaconda2/3ML_env/lib/python2.7/site-packages/fermipy/gtutils.py", line 6, in <module>
import pyLikelihood as pyLike
File "/home/max/anaconda2/3ML_env/FST/Fermi1/lib/python/pyLikelihood.py", line 7, in <module>
import lib_pyLikelihood
ImportError: libLikelihood.so: cannot open shared object file: No such file or directory

如果我将LD_LIBRARY_PATH更改为[/ home / max / anaconda2 / 3ML_env / FST / Fermi1 / lib / python],我会收到同样的错误。奇怪的是,让LD_LIBRARY_PATH变量首先打开程序所需的程序,两个程序包都处于活动状态,这似乎导致了其他问题。例如,'pip'不再具有功能性

pip --version
Traceback (most recent call last):
File "/home/max/anaconda2/3ML_env/bin/pip", line 7, in <module>
from pip import main
File "/home/max/anaconda2/3ML_env/lib/python2.7/site-packages/pip/__init__.py", line 4, in <module>
import locale
File "/home/max/anaconda2/3ML_env/lib/python2.7/locale.py", line 16, in <module>
import operator
ImportError: /home/max/anaconda2/3ML_env/lib/python2.7/lib-dynload/operator.so: undefined symbol: _PyUnicodeUCS4_AsDefaultEncodedString

遍布堆栈的人都有这个问题,其中python无法识别.so文件,并且收到的答案主要与此LD_LIBRARY_PATH变量相关。一位朋友告诉我,我可能会问错误安装python,以执行特定任务。

此外,这是我得到的python sys.path

['', '/home/max/anaconda2/3ML_env/FST/Fermi1/lib/python',
 '/home/max/anaconda2/3ML_env/FST/Fermi1/lib',
 '/home/max',
 '/home/max/anaconda2/3ML_env/lib/python2.7',
 '/home/max/anaconda2/3ML_env/lib/python2.7/plat-x86_64-linux-gnu',
 '/home/max/anaconda2/3ML_env/lib/python2.7/lib-tk', 
'/home/max/anaconda2/3ML_env/lib/python2.7/lib-old',
 '/home/max/anaconda2/3ML_env/lib/python2.7/lib-dynload', 
'/home/max/anaconda2/lib/python2.7',
 '/home/max/anaconda2/lib/python2.7/lib-tk',
 '/home/max/anaconda2/3ML_env/lib/python2.7/site-packages']

我的所有错误都来自.so文件。我真的不知道发生了什么。我很乐意提供你们要求的任何其他变量。对任何想法开放。大家先谢谢了。我非常感激

0 个答案:

没有答案