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

自闭症网瘾萝莉.ら 提交于 2020-12-28 18:28:26

问题


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 (i.e 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

回答1:


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 



回答2:


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



回答3:


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).




回答4:


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



来源:https://stackoverflow.com/questions/58649177/python3-7-error-while-loading-shared-libraries-libpython3-7m-so-1-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!