[英]pip upgrading within the Python Alpine image: ERROR: Could not install packages due to an OSError: [Errno 39] Directory not empty: 'urllib3'
When I use pip to install stuff it tells me当我使用 pip 安装东西时,它告诉我
WARNING: You are using pip version 22.0.4; however, version 22.2 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
However when I try to install it I get a problem但是,当我尝试安装它时,我遇到了问题
/ # /usr/local/bin/python -m pip install --upgrade pip
Requirement already satisfied: pip in /usr/local/lib/python3.7/site-packages (22.0.4)
Collecting pip
Downloading pip-22.2-py3-none-any.whl (2.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 21.2 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
ERROR: Could not install packages due to an OSError: [Errno 39] Directory not empty: 'urllib3'
The weird thing here is this is easily reproducable.这里奇怪的是这很容易重现。 I'm using the
python:3.7-alpine
image.我正在使用
python:3.7-alpine
图像。
You can see this error like this,你可以看到这样的错误,
podman run -ti python:3.7-alpine /usr/local/bin/python -m pip install --upgrade pip
What the right way to upgrade Python 3.7 using the Alpine image, such that I don't get this error,使用 Alpine 映像升级 Python 3.7 的正确方法是什么,这样我就不会收到此错误,
ERROR: Could not install packages due to an OSError: [Errno 39] Directory not empty: 'urllib3'
错误:由于 OSError 无法安装软件包:[Errno 39] 目录不为空:'urllib3'
You can see the Dockerfile to create the python:3.7-alpine
image here您可以在此处查看创建
python:3.7-alpine
映像的 Dockerfile
In general, it may be helpful to avoid using python in alpine.一般来说,避免在 alpine 中使用 python 可能会有所帮助。 This is from Docker :
这是来自 Docker :
The main caveat to note is that it does use musl libc instead of glibc and friends, so software will often run into issues depending on the depth of their libc requirements/assumptions
需要注意的主要警告是它确实使用 musl libc 而不是 glibc 和朋友,因此软件经常会遇到问题,具体取决于它们的 libc 要求/假设的深度
So while alpine is great for its small size, it can be a pain to use because of this.因此,虽然 alpine 因其体积小而出色,但因此使用起来可能会很痛苦。 If your project allows it, I would recommend using the debian-based image.
如果您的项目允许,我建议您使用基于 debian 的映像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.