libpython2.7.so.1.0:无法打开共享对象文件:没有那个文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20842732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 21:21:28  来源:igfitidea点击:

libpython2.7.so.1.0: cannot open shared object file: No such file or directory

pythonshared-libraries

提问by yehudahs

I have trying to run python script from the terminal but getting the next error message :

我试图从终端运行 python 脚本,但收到下一条错误消息:

ImportError: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

if I run print sys.version I get :

如果我运行 print sys.version 我得到:

>>> import sys
>>> print sys.version
2.7.3 (default, Feb 26 2013, 16:27:39)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]

and if I run ldd /usr/local/bin/python

如果我运行 ldd /usr/local/bin/python

>> ldd /usr/local/bin/python
        linux-vdso.so.1 =>  (0x00007fff219ff000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003300c00000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000003300800000)
        libutil.so.1 => /lib64/libutil.so.1 (0x0000003310e00000)
        libm.so.6 => /lib64/libm.so.6 (0x0000003300000000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003300400000)
        /lib64/ld-linux-x86-64.so.2 (0x00000032ffc00000)

I don't understand which python do I have ? why running this python script from the terminal is failing ? I have tried to run

我不明白我有哪条蟒蛇?为什么从终端运行这个 python 脚本失败?我试过跑

export LD_LIBRARY_PATH=/usr/local/lib/python2.7/

with no luck...

没有运气...

BTW - I have managed to debug this script in eclipse with the python plug-in, and when I look at the debug configuration I see that the PYTHONPATH is set for :

顺便说一句 - 我已经设法使用 python 插件在 eclipse 中调试这个脚本,当我查看调试配置时,我看到 PYTHONPATH 设置为:

/..../eclipse/plugins/org.python.pydev_3.1.0.201312121632/pysrc/pydev_sitecustomize:/..../workspace/style_checker/src:/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg:/usr/local/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg:/usr/local/lib/python2.7:/usr/local/lib/python2.7/plat-linux2:/usr/local/lib/python2.7/lib-tk:/usr/local/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/site-packages

so eclipse manage somehow to find this python2.7 libs... so how can I do it with out eclipse and from the command line ? what am I doing wrong ? using CentOS6.

所以 eclipse 设法以某种方式找到这个 python2.7 库......那么我如何在没有 eclipse 和命令行的情况下做到这一点?我究竟做错了什么 ?使用 CentOS6。

回答by Antony

Perhaps you could try the answer at https://stackoverflow.com/a/1100297/3559967. The author of that question also stated that the LD_LIBRARY_PATH approach did not work for him, but adding the library path to /etc/ld.so.confand running ldconfigworked.

也许您可以在https://stackoverflow.com/a/1100297/3559967尝试答案。该问题的作者还表示 LD_LIBRARY_PATH 方法对他不起作用,但将库路径添加到/etc/ld.so.conf并运行ldconfig有效。

回答by CK.Nguyen

Try to find file libpython2.7.so.1.0:

尝试查找文件libpython2.7.so.1.0

locate libpython2.7.so.1.0

locate libpython2.7.so.1.0

In my case, it show out put:

在我的情况下,它显示:

/opt/rh/python27/root/usr/lib64/libpython2.7.so.1.0

/opt/rh/python27/root/usr/lib64/libpython2.7.so.1.0

Then paste line /opt/rh/python27/root/usr/lib64to file /etc/ld.so.conf

然后将行粘贴/opt/rh/python27/root/usr/lib64到文件/etc/ld.so.conf

And run ldconfig. It solved my problem. Goodluck!

并运行ldconfig。它解决了我的问题。祝你好运!

回答by John Kitonyo

For some reason these two have worked perfectly for me:

出于某种原因,这两个对我来说非常有效:

apt-get install libpython2.7
sudo apt-get install libatlas3-base

I found them hereand here

我在这里这里找到了它们

回答by ecoe

This isn't a subject I'm keen on, but my understanding is for Linux machines especially (where you're compiling python binaries) that shared library directories should be specified at the compile step.

这不是我热衷的主题,但我的理解是对于 Linux 机器,尤其是(您正在编译 python 二进制文件的地方)应该在编译步骤指定共享库目录

For instance, following the linked example, here is how I ensure libpython2.7.so.1.0is included in additionto other libraries:

例如,按照链接的示例,以下是我确保除了其他库之外libpython2.7.so.1.0还包含的方法:

./configure --enable-shared \
        --prefix=/directory/for/Python-2.7.15 \
        LDFLAGS="-Wl,--rpath=/usr/local/lib -Wl,--rpath=/directory/for/Python-2.7.15"

Notice I'm also installing python to a fixed directory of my choosing, via the --prefixoption. That might not be necessary for you, but I did it to provide a solution for the general case where your python install might be located anywhere.

请注意,我还通过--prefix选项将 python 安装到我选择的固定目录。这对您来说可能不是必需的,但我这样做是为了为您的 python 安装可能位于任何地方的一般情况提供解决方案。

With the above solution, I never have to export LD_LIBRARY_PATHor mess with ldconfig

使用上述解决方案,我永远不必导出LD_LIBRARY_PATH或弄乱ldconfig

回答by u6294745

I solved it by using "export LD_LIBRARY_PATH="${WORK_PATH}/venv/lib".

我通过使用“export LD_LIBRARY_PATH="${WORK_PATH}/venv/lib”解决了它。

回答by rrpr

Adding to the Correct answer:

添加到正确答案:

Multiple question on how to the following : Then paste line /opt/rh/python27/root/usr/lib64 to file /etc/ld.so.conf

关于如何解决以下问题的多个问题:然后将 /opt/rh/python27/root/usr/lib64 行粘贴到文件 /etc/ld.so.conf

The correct way to do this add a new file in /etc/ld.so.conf.d/, and add the line above in that file.

正确的做法是在 /etc/ld.so.conf.d/ 中添加一个新文件,并在该文件中添加上面的行。

回答by Clément Hurlin

I was having a similar issue while executing a 32 bits gdb binary on a 64 bits Linux:

在 64 位 Linux 上执行 32 位 gdb 二进制文件时,我遇到了类似的问题:

arm-eabi-gdb: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

and I solved it by installing libpython2.7:i386(note the :i386 suffix)

我通过安装解决了它libpython2.7:i386(注意 :i386 后缀)