我尝试在Docker中安装requirements.txt文件,当我尝试安装importlib时,我在中安装了大约30个包,并收到了以下错误:
无法执行setup.py
,因为setuptools在建置环境中无法使用。
以下是完整的错误消息:
Collecting importlib==1.0.4
# 9 14.42 Downloading importlib-1.0.4.zip (7.1 kB)
# 9 14.43 Preparing metadata (setup.py): started
# 9 14.45 Preparing metadata (setup.py): finished with status 'error'
# 9 14.45 error: subprocess-exited-with-error
# 9 14.45
# 9 14.45 × python setup.py egg_info did not run successfully.
# 9 14.45 │ exit code: 1
# 9 14.45 ╰─> [1 lines of output]
# 9 14.45 ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
# 9 14.45 [end of output]
# 9 14.45
# 9 14.45 note: This error originates from a subprocess, and is likely not a problem with pip.
# 9 14.45 error: metadata-generation-failed
# 9 14.45
# 9 14.45 × Encountered error while generating package metadata.
# 9 14.45 ╰─> See above for output.
# 9 14.45
# 9 14.45 note: This is an issue with the package mentioned above, not pip.
# 9 14.45 hint: See above for details.
在Dockerfile中,我尝试在安装软件包之前安装setuptools:
RUN python3 -m pip install setuptools
RUN python3 -m pip install -r requirements.txt
更多详情:我的python版本是3.9,pip版本是22.1.2
当我这样做
easy_install --version
,我拿
setuptools 41.0.1 from /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (Python 2.7)
但是,当我试图用pip安装setuptools时,它说我有python3. 9的62. 3. 3版本
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (62.3.3)
任何帮助都是非常感谢的,让我知道如果我应该提供任何进一步的细节。
1条答案
按热度按时间xa9qqrwz1#
正如在注解中提到的,出现这个错误是因为您试图在Python 3.9上安装
importlib
,而它只适用于更老的Python版本。只需从您的
requirements.txt
文件中删除importlib
。