I have trying to run python script from the terminal but getting the next error message :
ImportError: libpython2.7.so.1.0: cannot open shared object file: N
I was having a similar issue while executing a 32 bits gdb binary on a 64 bits Linux:
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)
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
The correct way to do this add a new file in /etc/ld.so.conf.d/, and add the line above in that file.
Try to find file 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
Then paste line /opt/rh/python27/root/usr/lib64
to file /etc/ld.so.conf
And run ldconfig
.
It solved my problem. Goodluck!
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.
For instance, following the linked example, here is how I ensure libpython2.7.so.1.0
is included in addition to other libraries:
./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 --prefix
option. 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.
With the above solution, I never have to export LD_LIBRARY_PATH
or mess with ldconfig
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.conf
and running ldconfig
worked.
For some reason these two have worked perfectly for me:
apt-get install libpython2.7
sudo apt-get install libatlas3-base
I found them here and here