Python3.7: error while loading shared libraries: libpython3.7m.so.1.0
Solution 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
Solution 2
I just installed the required library using:
sudo apt-get install libpython3.7
Solution 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/[email protected]/3.8.3/lib
works for me (no reboot need).
Solution 4
pip3 install uwsgi
worked for me

user_12
Updated on July 12, 2022Comments
-
user_12 5 months
I have two versions Python-2.7 , Python-3.5 which I was able to access with
python(pip)
andpython3(pip3)
command respectively. Then I have installed an another version ofpython (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:
[email protected]:~$ 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
-
furas about 3 yearsdid you check if apt on Debian doesn't have precompiled Python3.7 ? On Linux Mint I use
apt
to install precompiled Python 3.7 from unofficial repo for Ubuntu - maybe it can works also for Debian - launchpad.net/~deadsnakes/+archive/ubuntu/ppa -
furas about 3 yearsusing
find
orlocate
you can try to findlibpython3.7m.so.1.0
and compare its path with full path tolibpython3.5
- maybe you have to manually move it to correct folder. -
user_12 about 3 yearsI tried to update python using
sudo apt install python2
but it returned python 3.5 as the latest version available. So that's why I installed it via above method. -
user_12 about 3 years@furas can you provide the commands on how to do that. I'm new to linux os. I really have no idea on how to do it.
-
furas about 3 yearsI'm not sure if
locate
is always installed. It creates database with all filename -sudo updatedb
- and later you can search -locate libpython3.7m.so.1.0
. Because it uses database so it search very fast but from time to time you have to useupdatedb
to update data in this database. -
furas about 3 yearsnormally should be installed
find
. It search directly in folders -sudo find / -name libpython3.7
- so it check current content on disk but it may run much slower. -
user_12 about 3 years@furas As you mentioned I tried using
locate libpython3.7m.so.1.0
and it returned/usr/local/lib/libpython3.7m.so.1.0
-
furas about 3 yearsand what did you get for
libpython3.5m
? Is it in the same folder ? If not then try to copylibpython3.7m.so.1.0
to folder where you havelibpython3.5m
-
user_12 about 3 years@furas can you check the question I updated what I've got for searching
locate libpython3.5m
. It returned multiple locations. Can you tell me what command I should use to copy everything correctly. -
furas about 3 yearsI have
/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
and/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu/libpython3.7m.so
similar to folders withlibpython3.5m
. The same with other files:libpython3.7m.so.1
,libpython3.7m.so
andlibpython3.7m.a
-
furas about 3 yearsI'm not sure if Debian uses
Python3
to run something in system but maybe you should usemake install
instead ofmake altinstall
-
user_12 about 3 yearsyes even I wasn't sure so I used
make altinstall
. So is there a way to remove everything so I can again install it withmake install
. I don't know the commands to remove. -
furas about 3 yearsFor Python
install
runsaltinstall
and few other commands so you don't have to remove it. Difference in details between “make install” and “make altinstall”
-
-
user_12 about 3 yearsit worked when I used
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
but do I need to use this command everytime before using python3.7? -
user_12 about 3 yearswhen I used
sudo ldconfig /usr/local/lib
it returned some output. I've posted it in the question above. I think it's a error saying it's not a symbolic link or something. -
MEE about 3 yearsNothing to worry about in that output.
-
user_12 about 3 yearsSo it it done now? I mean will it work always even after reboot?
-
MEE about 3 yearsYes, it should work after rebooting if you made the changes permanent as explained above. If you only used
export
in the current shell it will only impact the current shell session. -
user_12 about 3 yearsI haven't make changes permanent. Can you please also include those steps in the answer above. I really don't know how to do it?
-
MEE about 3 yearsLet us continue this discussion in chat.
-
Philipp Möhler over 2 yearsThanks, also came up with this - since docker-compose version 1.25.5 it was broken for me in a Ubuntu 18.04.4 environment using linuxbrew inside WSL with message: /home/linuxbrew/.linuxbrew/Cellar/docker-compose/1.25.5_2/libexec/bin/python3.8: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory
-
Juancki about 2 years
sudo ldconfig
did it for me -
DragonLord over 1 yeargets libpython3.7 but does not seem to pick up libpython3.7m, from deadsnakes and defaults.