英文:
Can't install Poetry in Ubuntu 20.04 Docker image due to setuptools error
问题
I'm trying to build the following Dockerfile:
FROM ubuntu:20.04
RUN apt-get update && \
apt-get install -y curl software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
apt install -y python3.11 python3.11-distutils && \
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11 && \
python3.11 -m pip install poetry==1.2.2
However, it fails to install poetry
with the following error message:
Collecting msgpack>=0.5.2
Downloading msgpack-1.0.4.tar.gz (128 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 128.1/128.1 kB 15.2 MB/s eta 0:00:00
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
ERROR: Exception:
Traceback (most recent call last):
...
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'setuptools'
If I replace the install command for Poetry at the end and replace it with python3.11 -m pip list
then the output clearly shows setuptools
being installed:
Package Version
------------------- -----------
...
setuptools 67.2.0
...
I can also import setuptools
without problems when I open a Python interpreter. What is going on?
Note that I'm unable to use a newer Ubuntu version or pythonX.Y
image due to other requirements.
英文:
I'm trying to build the following Dockerfile:
FROM ubuntu:20.04
RUN apt-get update && \
apt-get install -y curl software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
apt install -y python3.11 python3.11-distutils && \
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11 && \
python3.11 -m pip install poetry==1.2.2
However, it fails to install poetry
with the following error message:
Collecting msgpack>=0.5.2
Downloading msgpack-1.0.4.tar.gz (128 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 128.1/128.1 kB 15.2 MB/s eta 0:00:00
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
ERROR: Exception:
Traceback (most recent call last):
...
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'setuptools'
If I replace the install command for Poetry at the end and replace it with python3.11 -m pip list
then the output clearly shows setuptools
being installed:
Package Version
------------------- -----------
...
setuptools 67.2.0
...
I can also import setuptools
without problems when I open a Python interpreter. What is going on?
Note that I'm unable to use a newer Ubuntu version or pythonX.Y
image due to other requirements.
答案1
得分: 0
不要将poetry安装到全局Python环境(也不要安装到项目虚拟环境中),否则它会影响项目/系统依赖项的包兼容性。
请参阅poetry文档,了解如何在进行“手动安装”时为poetry提供其自己的虚拟环境。否则,可以使用官方的poetry安装脚本,它会为您完成这些操作。
英文:
Don't install poetry into the global Python environment (nor into your project venv), or it'll influence package compatibility within your project/system dependencies.
See poetry docs on how to give poetry its own venv when doing a "manual install". Otherwise, use the official poetry install script which does that for you.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论