sans sans - 5 months ago 33
Python Question

Python executable not finding libpython shared library

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

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

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

/usr/local/bin/python: error while loading shared libraries: cannot open shared object file: No such file or directory

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

ldd /usr/local/bin/python => not found => /lib64/ (0x00000030e9a00000) => /lib64/ (0x00000030e9200000) => /lib64/ (0x00000030fa200000) => /lib64/ (0x00000030e9600000) => /lib64/ (0x00000030e8e00000)
/lib64/ (0x00000030e8a00000)

How do I tell Python where to find libpython?


Try the following:

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

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

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

  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.

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