简体   繁体   English

Python Alpine 映像中的 pip 升级:错误:由于 OSError 无法安装软件包:[Errno 39] 目录不为空:'urllib3'

[英]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.

相关问题 错误:由于 OSError 无法安装软件包:[Errno 39] 目录不为空 - ERROR: Could not install packages due to an OSError: [Errno 39] Directory not empty 如何安装 requirements.txt pip 错误->由于 OSError 无法安装软件包:[Errno 2] 没有这样的文件或目录 - How to install requirements.txt pip error ->Could not install packages due to an OSError: [Errno 2] No such file or directory Python:由于 OSError 无法安装软件包:[Errno 2] 没有这样的文件或目录 - Python: Could not install packages due to an OSError: [Errno 2] No such file or directory Python:由于 OSError 无法安装包:[Errno 2] 没有这样的文件或目录 - Python: Could not install packages due to an OSError: [Errno 2] No such file or directory Python Pandas “错误:由于 OSError 无法安装软件包:没有这样的文件或目录:” - Python Pandas “Error: Could not install packages due to an OSError: No such file or directory:” 错误:由于 OSError 无法安装软件包:[[Errno 22] 无效参数:'/tmp/pip-req-build] - ERROR: Could not install packages due to an OSError: [[Errno 22] Invalid argument: '/tmp/pip-req-build] python,conda:错误:由于 OSError 无法安装软件包:[WinError 5] 访问被拒绝:'d:\\\\anaconda3\\\\envs\\\\python39\\\\scripts\\\\pip.exe' - python, conda: ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'd:\\anaconda3\\envs\\python39\\scripts\\pip.exe' Pip 安装包错误:由于 OSError 无法安装包 - Pip Install Package Error: Could not install packages due to an OSError docker 错误:由于 OSError 无法安装软件包:[Errno 2] - docker ERROR: Could not install packages due to an OSError: [Errno 2] 错误:由于 OSError 无法安装软件包:[Errno 22] 参数无效 - ERROR: Could not install packages due to an OSError: [Errno 22] Invalid argument
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM