Python似乎无法找到库 - 用户和系统python版本之间的冲突

时间:2016-08-30 17:00:24

标签: python

让我们从最顶端开始吧。

这是我目前遇到的问题:

bob@me:~/cloud/simtk/opensim_core_install/lib/python2.7/site-packages$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import opensim
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "opensim/__init__.py", line 2, in <module>
    from common import *
  File "opensim/common.py", line 21, in <module>
    _common = swig_import_helper()
  File "opensim/common.py", line 20, in swig_import_helper
    return importlib.import_module('_common')
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named _common

对于那些对细节感兴趣的人,我试图使用这个package,特别是最前沿的版本。

从我可以从万维网和其他来源设计,我在我的机器上安装了两个版本的python

bob@me:/usr$ which python && python --version
/usr/bin/python
Python 2.7.6

bob@me:/usr/local$ /usr/local/bin/python2.7 --version
Python 2.7.9

现在,在构建上面的包时,必须引用我有两个文件的libpython2.7.so文件(它们都是系统,也就是说/usr/local/中没有一个文件:

bob@me:/usr$ find . -name 'libpython2.7.so'
./lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so
./lib/x86_64-linux-gnu/libpython2.7.so

我通过运行

来构建包装
python setup.py install

里面

~/cloud/simtk/opensim_core_install/lib/python2.7/site-packages

它所在的位置。现在当它运行时,它将全部放在/usr/local/目录而不是系统范围内,这就是我认为出现问题的地方。

bob@me:~/cloud/simtk/opensim_core_install/lib/python2.7/site-packages$ sudo python setup.py install
[sudo] password for bob: 
running install
running bdist_egg
running egg_info
writing opensim.egg-info/PKG-INFO
writing top-level names to opensim.egg-info/top_level.txt
writing dependency_links to opensim.egg-info/dependency_links.txt
reading manifest file 'opensim.egg-info/SOURCES.txt'
writing manifest file 'opensim.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/_analyses.so -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/tools.py -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/simbody.py -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/actuators.py -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/_simbody.so -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/__init__.py -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/analyses.py -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/_simulation.so -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/version.py -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/_tools.so -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/_actuators.so -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/common.py -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/simulation.py -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/_common.so -> build/bdist.linux-x86_64/egg/opensim
copying build/lib.linux-x86_64-2.7/opensim/__init__.pyc -> build/bdist.linux-x86_64/egg/opensim
byte-compiling build/bdist.linux-x86_64/egg/opensim/tools.py to tools.pyc
byte-compiling build/bdist.linux-x86_64/egg/opensim/simbody.py to simbody.pyc
byte-compiling build/bdist.linux-x86_64/egg/opensim/actuators.py to actuators.pyc
byte-compiling build/bdist.linux-x86_64/egg/opensim/analyses.py to analyses.pyc
byte-compiling build/bdist.linux-x86_64/egg/opensim/version.py to version.pyc
byte-compiling build/bdist.linux-x86_64/egg/opensim/common.py to common.pyc
byte-compiling build/bdist.linux-x86_64/egg/opensim/simulation.py to simulation.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying opensim.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying opensim.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying opensim.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying opensim.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
opensim.actuators: module references __file__
opensim.tools: module references __file__
opensim.analyses: module references __file__
opensim.simbody: module references __file__
opensim.common: module references __file__
opensim.simulation: module references __file__
creating 'dist/opensim-4.0-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing opensim-4.0-py2.7.egg
removing '/usr/local/lib/python2.7/dist-packages/opensim-4.0-py2.7.egg' (and everything under it)
creating /usr/local/lib/python2.7/dist-packages/opensim-4.0-py2.7.egg
Extracting opensim-4.0-py2.7.egg to /usr/local/lib/python2.7/dist-packages
opensim 4.0 is already the active version in easy-install.pth

Installed /usr/local/lib/python2.7/dist-packages/opensim-4.0-py2.7.egg
Processing dependencies for opensim==4.0
Finished processing dependencies for opensim==4.0

现在可能是因为这都是在/usr/local/中创建的,这就是为什么python的系统版本找不到相关的库?问题是,当我尝试使用/usr/local/bin/python2.7时,它仍然无法找到库。

另外我应该补充:

bob@me:~/cloud/simtk/opensim_core_install/lib/python2.7/site-packages$ ls *
setup.py

build:
bdist.linux-x86_64  lib.linux-x86_64-2.7

dist:
opensim-4.0-py2.7.egg

opensim:
actuators.py   _analyses.so  _common.so    simbody.py   simulation.py   tools.py
_actuators.so  common.py     __init__.py   simbody.pyc  _simulation.so  _tools.so
analyses.py    common.pyc    __init__.pyc  _simbody.so  tests           version.py

opensim.egg-info:
dependency_links.txt  PKG-INFO  SOURCES.txt  top_level.txt

bob@me:~$ echo $LD_LIBRARY_PATH 
:/local/bob/cloud/simtk/opensim_core_install/lib/python2.7/site-packages/opensim

1 个答案:

答案 0 :(得分:0)

根据您的问题,您尝试通过简单地运行python setup.py install来构建。

您必须按照自述文件中的说明进行操作,并使用与您的操作系统相对应的方法进行构建。