And*_*eng 8 python pip setuptools python-3.x docker
我正在尝试在 Docker 中安装一个requirements.txt 文件,当我在尝试安装 importlib 时收到此错误时,我将其设置为大约 30 个包:
\n无法执行,setup.py因为 setuptools 在构建环境中不可用。
这是完整的错误消息:
\nCollecting importlib==1.0.4\n#9 14.42 Downloading importlib-1.0.4.zip (7.1 kB)\n#9 14.43 Preparing metadata (setup.py): started\n#9 14.45 Preparing metadata (setup.py): finished with status 'error'\n#9 14.45 error: subprocess-exited-with-error\n#9 14.45 \n#9 14.45 \xc3\x97 python setup.py egg_info did not run successfully.\n#9 14.45 \xe2\x94\x82 exit code: 1\n#9 14.45 \xe2\x95\xb0\xe2\x94\x80> [1 lines of output]\n#9 14.45 ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.\n#9 14.45 [end of output]\n#9 14.45 \n#9 14.45 note: This error originates from a subprocess, and is likely not a problem with pip.\n#9 14.45 error: metadata-generation-failed\n#9 14.45 \n#9 14.45 \xc3\x97 Encountered error while generating package metadata.\n#9 14.45 \xe2\x95\xb0\xe2\x94\x80> See above for output.\n#9 14.45 \n#9 14.45 note: This is an issue with the package mentioned above, not pip.\n#9 14.45 hint: See above for details.\nRun Code Online (Sandbox Code Playgroud)\n在 Dockerfile 中,我在安装软件包之前尝试安装 setuptools:
\nRUN python3 -m pip install setuptools\nRUN python3 -m pip install -r requirements.txt\nRun Code Online (Sandbox Code Playgroud)\n一些进一步的细节:我的 python 版本是 3.9,pip 版本是 22.1.2
\n当我做
\neasy_install --version\nRun Code Online (Sandbox Code Playgroud)\n,我得到
\nsetuptools 41.0.1 from /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (Python 2.7)\nRun Code Online (Sandbox Code Playgroud)\n但是,当我尝试使用 pip 安装 setuptools 时,它说我的 python3.9 版本为 62.3.3
\nRequirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (62.3.3)\nRun Code Online (Sandbox Code Playgroud)\n非常感谢任何帮助,如果我需要提供任何进一步的详细信息,请告诉我。
\n正如评论中提到的,出现错误是因为您尝试importlib在 Python 3.9 上安装,而它仅适用于更旧的 Python 版本。
importlib只需从您的文件中删除即可requirements.txt。