我试图在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时,它说我有62.3.3版本的python3.9
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (62.3.3)
任何帮助都是非常感谢的,如果我需要提供更多的细节,请告诉我。
发布于 2022-07-06 13:36:58
正如注释中提到的,出现此错误是因为您试图在Python3.9上安装importlib
,而它只适用于更老的Python版本。
只需从您的importlib
文件中删除requirements.txt
。
https://stackoverflow.com/questions/72570910
复制相似问题