Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python:3.8 does not include /usr/lib/python3/dist-packages in sys.path #482

Closed
MarcelWaldvogel opened this issue May 10, 2020 · 3 comments
Closed
Labels
question Usability question, not directly related to an error with the image

Comments

@MarcelWaldvogel
Copy link

The following Dockerfile fails with ModuleNotFoundError:

FROM python:3.8
RUN apt update && apt install python3-urllib3
RUN python3 -c "import urllib3"

Adding ENV PYTHONPATH=/usr/lib/python3/dist-packages before the python3 command will make it run smoothly. So it ignores libraries installed by apt, which is e.g. essential for pygit2, which cannot be reasonable installed with pip/pip3.

@wglambert wglambert added the question Usability question, not directly related to an error with the image label May 11, 2020
@wglambert
Copy link

#43 (comment)

I'm not sure I'm following for what's gained by supporting this path besides encouraging people to mix Debian Python packages with pip install packages? (which is generally considered harmful)

I think if you're relying on Debian-packaged python dependencies, you're probably going to be better off going straight for either FROM debian or FROM buildpack-deps instead of trying to get this image to do what you might expect when mixing dependencies from APT and elsewhere.

https://packages.debian.org/buster/python3-urllib3
Python3 is a dependency, which will install Python from the Debian repo's alongside the image's compiled Python

@tianon
Copy link
Member

tianon commented May 11, 2020

Closing as duplicate of #43

@tianon tianon closed this as completed May 11, 2020
@MarcelWaldvogel
Copy link
Author

On ARM, pip3 install pygit2 fails at compile-time, as it is missing git2.h. Trying to first apt update && apt install libgit2-dev fails, because, again at compile-time, a version mismatch between libgit2-dev (0.27.4) and pygit2 (1.2.1) is detected. Including rules for selecting the appropriate pygit2 version is horrible, so requiring pygit2 along with other packages from pypi essentially requires mixing native packages and python packages.

But I might consider switching to FROM debian, even though multiarch building will be much slower then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants