Python: libpython3.7m.so.1.0: cannot open shared object file on multiple Python Docker versions

Created on 25 May 2020  路  4Comments  路  Source: docker-library/python

I recently upgraded my Ubuntu server to 20.04 LTS and am getting the following error when attempting to use official Python Docker instances.

Error loading shared library libpython3.8.so.1.0: No such file or directory (needed by 
/usr/local/bin/python3)

I have tried this with multiple Python tags including python:3.7, python:3.8, python3.8-slim, and python:3.8-alpine.

Additionally, I have discovered that the Python shared libraries in /usr/local/lib are inaccessible due to a permission error. The permission error still exists even after explicitly setting the file permissions to 777.

/usr/local/lib # cat /usr/local/lib/libpython3.8.so
cat: can't open '/usr/local/lib/libpython3.8.so': Permission denied
/usr/local/lib # ls -l
total 3524
lrwxrwxrwx    1 root     root            19 May 20 20:47 libpython3.8.so -> libpython3.8.so.1.0
-rwxr-xr-x    1 root     root       3581088 May 20 20:47 libpython3.8.so.1.0
-rwxr-xr-x    1 root     root         13672 May 20 20:47 libpython3.so
drwxr-xr-x    2 root     root          4096 May 20 20:47 pkgconfig
drwxr-xr-x    1 root     root          4096 May 20 20:47 python3.8

Steps to Recreate the Issue:

  1. Log into a fresh install of Ubuntu server 20.04
  2. apt install docker.io python3-dev
  3. root@ewok:/home/user# docker run -it --rm python:3.8-alpine sh / # python3 Error loading shared library libpython3.8.so.1.0: No such file or directory (needed by /usr/local/bin/python3) Error relocating /usr/local/bin/python3: Py_BytesMain: symbol not found

Server Information:

root@ewok:/home/user# uname -a
Linux ewok 5.4.0-31-generic #35-Ubuntu SMP Thu May 7 20:20:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
root@ewok:/home/user# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
question

Most helpful comment

I had the same issue with Ubuntu 20.04 (not server). I had upgraded from 18.04 so it wasn't a fresh install. Clearing the docker cache didn't solve the problem, although sudo apt remove docker.io python3-dev followed by sudo apt install docker.io python3-dev fixed it.

All 4 comments

I can't reproduce, but I'm also not using Ubuntu Server 20.04. If the host's OS/environment is affecting Docker then that's not something we can alleviate in the image

$ docker run -it --rm python:3.8-alpine sh
Unable to find image 'python:3.8-alpine' locally
3.8-alpine: Pulling from library/python
cbdbe7a5bc2a: Pull complete 
26ebcd19a4e3: Pull complete 
a29d43ca1bb4: Pull complete 
979dbbcf63e0: Pull complete 
30beed04940c: Pull complete 
Digest: sha256:690f6313439d755b558ebf040560889947dfe0c74dbdb00002dca7460b0281b6
Status: Downloaded newer image for python:3.8-alpine

/ # which python3
/usr/local/bin/python3

/ # python3
Python 3.8.3 (default, May 20 2020, 20:46:20) 
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

If you have a more reliable reproducer then we could troubleshoot the issue more but this seems more like a problem with the host's environment

@wglambert I attempted to recreate again and after explicitly wiping the docker cache it looks like it's working. Perhaps it was some weird corrupted state issue.

I had the same issue with Ubuntu 20.04 (not server). I had upgraded from 18.04 so it wasn't a fresh install. Clearing the docker cache didn't solve the problem, although sudo apt remove docker.io python3-dev followed by sudo apt install docker.io python3-dev fixed it.

@stanleybak Thank you for sharing this, exactly my issue!

Was this page helpful?
0 / 5 - 0 ratings