Python 可执行文件找不到 libpython 共享库 [英] Python executable not finding libpython shared library

查看:93
本文介绍了Python 可执行文件找不到 libpython 共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 CentOS 5 上安装 Python 2.7.我构建和安装 Python 如下

I am installing Python 2.7 on CentOS 5. I built and installed Python as follows

./configure --enable-shared --prefix=/usr/local
make
make install

当我尝试运行/usr/local/bin/python 时,我收到此错误消息

When I try to run /usr/local/bin/python, I get this error message

/usr/local/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

当我在/usr/local/bin/python 上运行 ldd 时,我得到

When I run ldd on /usr/local/bin/python, I get

ldd /usr/local/bin/python
    libpython2.7.so.1.0 => not found
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00000030e9a00000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00000030e9200000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00000030fa200000)
    libm.so.6 => /lib64/libm.so.6 (0x00000030e9600000)
    libc.so.6 => /lib64/libc.so.6 (0x00000030e8e00000)
    /lib64/ld-linux-x86-64.so.2 (0x00000030e8a00000)

如何告诉 Python 在哪里可以找到 libpython?

How do I tell Python where to find libpython?

推荐答案

尝试以下操作:

LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/python

/usr/local/lib 替换为您安装 libpython2.7.so.1.0 的文件夹(如果它不在 /usr/local 中)/lib.

Replace /usr/local/lib with the folder where you have installed libpython2.7.so.1.0 if it is not in /usr/local/lib.

如果这有效并且您希望更改永久有效,您有两个选择:

If this works and you want to make the changes permanent, you have two options:

  1. export LD_LIBRARY_PATH=/usr/local/lib 添加到您的主目录中的 .profile(这仅在您使用加载新的 shell 实例启动时的这个文件).此设置只会影响您的用户.

  1. Add export LD_LIBRARY_PATH=/usr/local/lib to your .profile in your home directory (this works only if you are using a shell which loads this file when a new shell instance is started). This setting will affect your user only.

/usr/local/lib 添加到 /etc/ld.so.conf 并运行 ldconfig.这当然是系统范围的设置.

Add /usr/local/lib to /etc/ld.so.conf and run ldconfig. This is a system-wide setting of course.

这篇关于Python 可执行文件找不到 libpython 共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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