简体   繁体   中英

Python3.7: error while loading shared libraries: libpython3.7m.so.1.0

I have two versions Python-2.7, Python-3.5 which I was able to access with python(pip) and python3(pip3) command respectively. Then I have installed an another version of python (ie 3.7.5) .

I have used these commands to install it.

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev

wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
tar xvf Python-3.7.5.tgz
cd Python-3.7.5
./configure --enable-optimizations --enable-shared
make -j6
sudo make altinstall

Everything was successful but the only issue is I was not able to access Python-3.7 using the command python3.7 .

When I used python3.7 it returned this following error:

python3.7: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

Can anyone please help me regarding how to fix this issue?

Info: OS : Debian GNU/Linux 9.11 (stretch)

Output when I type:

user_83@debian-241:~$ whereis python     
python: /usr/bin/python3.5m-config 
/usr/bin/python3.5m 
/usr/bin/python2.7-config 
/usr/bin/python3.5 
/usr/bin/python2.7 
/usr/bin/python 
/usr/bin/python3.5-config 
/usr/lib/python3.5 
/usr/lib/python2.7 
/etc/python3.5 
/etc/python2.7 
/etc/python 
/usr/local/bin/python3.7m 
/usr/local/bin/python3.7 
/usr/local/bin/python3.7m-config 
/usr/local/lib/python3.5 
/usr/local/lib/python2.7 
/usr/local/lib/python3.7
/usr/include/python3.5m 
/usr/include/python3.5 
/usr/include/python2.7 
/usr/share/python 
/usr/share/man/man1/python.1.gz

UPDATE:

locate libpython3.5m

/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/libpython3.5m-pic.a
/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/libpython3.5m.a
/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/libpython3.5m.so
/usr/lib/x86_64-linux-gnu/libpython3.5m.a
/usr/lib/x86_64-linux-gnu/libpython3.5m.so
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0

locate libpython3.7m
/usr/local/lib/libpython3.7m.so
/usr/local/lib/libpython3.7m.so.1.0
/usr/local/lib/python3.7/config-3.7m-x86_64-linux-gnu/libpython3.7m.a


sudo ldconfig /usr/local/lib 

ldconfig: /usr/lib/libnvinfer.so.5 is not a symbolic link
ldconfig: /usr/lib/libnvonnxparser_runtime.so.0 is not a symbolic link
ldconfig: /usr/lib/libnvonnxparser.so.0 is not a symbolic link
ldconfig: /usr/lib/libnvparsers.so.5 is not a symbolic link
ldconfig: /usr/lib/libnvinfer_plugin.so.5 is not a symbolic link

You need to add /usr/local/lib/ to the library search path. You can call the following in the current shell before running python3.7 :

export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib

Or run ldconfig to add the path to the linker cache:

sudo ldconfig /usr/local/lib 

Thanks All for sharing, but none of these worked for me, instead I just installed the required library using:

sudo apt-get install libpython3.7

I'm using homebrew/linuxbrew to manage my latest python3 version. Doing this export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/home/linuxbrew/.linuxbrew/Cellar/python@3.8/3.8.3/lib works for me (no reboot need).

If someone is still looking for a solution due to Pycharm IDE

Situation:

  • OS: ubuntu 18.04.4
  • This Problem occurred after the installation of caffe (cuda).

Weirdly enough it works if python script is executed from the terminal but as soon I use Pycharm IDE it shows above error


Solution:

What worked is a solution by @Vladstein Vomithler and @Dharman

I lack the understanding of the problem and why it occurred, it would be very helpful if someone can comment about that

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM