英文:
error: legacy-install-failure when installing apex
问题
你遇到的错误是因为在安装 apex 库时,系统无法找到 'packaging' 模块,导致 metadata 生成失败。这可能是版本兼容性问题或者包的依赖关系出了问题。以下是解决该问题的一些方法:
-
更新pip:首先尝试更新你的pip版本,可能你使用的pip版本存在一些bug。
pip install --upgrade pip
-
检查依赖关系:确保你的系统中已经安装了必要的依赖包,你可以手动安装 'packaging' 模块:
pip install packaging
-
检查Python环境:确保你的Python环境没有问题。有时候,不同的Python环境(比如系统Python和虚拟环境)可能会导致依赖关系错误。
-
检查apex源代码:如果以上步骤都没有解决问题,尝试检查一下Apex源代码,确保它的依赖关系和你的系统兼容。你也可以尝试查看Apex库的GitHub页面,看看是否有类似的问题报告或解决方案。
希望以上方法中的某一个能够帮助你解决这个问题。
英文:
I followed the method(https://github.com/NVIDIA/apex#quick-start) to install apex with CUDA and C++ extensions(Linux), but I got the error in the picture.
Local environment version: pytorch:1.13.1+cuda:11.7
Command:
git clone github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
Error:
Using pip 23.0.1 from /home/kang/miniconda3/envs/atlop/lib/python3.9/site-packages/pip (python 3.9)
WARNING: Implying --no-binary=:all: due to the presence of --build-option / --global-option / --install-option. Consider using --config-settings for more flexibility.
DEPRECATION: --no-binary currently disables reading from the cache of locally built wheels. In the future --no-binary will not influence the wheel cache. pip 23.1 will enforce this behaviour change. A possible replacement is to use the --no-cache-dir option. You can use the flag --use-feature=no-binary-enable-wheel-cache to test the upcoming behaviour. Discussion can be found at https://github.com/pypa/pip/issues/11453
Processing /hdd2/code_zy/ATLOP/apex
Running command python setup.py egg_info
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/hdd2/code_zy/ATLOP/apex/setup.py", line 4, in <module>
from packaging.version import parse, Version
ModuleNotFoundError: No module named 'packaging'
error: subprocess-exited-with-error
python setup.py egg_info did not run successfully.
exit code: 1
See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /home/kang/miniconda3/envs/atlop/bin/python -c '
exec(compile('"'"''"'"''"'"'
# This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
#
# - It imports setuptools before invoking setup.py, to enable projects that directly
# import from `distutils.core` to work with newer packaging standards.
# - It provides a clear error message when setuptools is not installed.
# - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
# setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
# manifest_maker: standard file '"'"'-c'"'"' not found".
# - It generates a shim setup.py, for handling setup.cfg-only projects.
import os, sys, tokenize
try:
import setuptools
except ImportError as error:
print(
"ERROR: Can not execute `setup.py` since setuptools is not available in "
"the build environment.",
file=sys.stderr,
)`enter code here`
sys.exit(1)
__file__ = %r
sys.argv[0] = __file__
if os.path.exists(__file__):
filename = __file__
with tokenize.open(__file__) as f:
setup_py_code = f.read()
else:
filename = "<auto-generated setuptools caller>"
setup_py_code = "from setuptools import setup; setup()"
exec(compile(setup_py_code, filename, "exec"))
'"'"''"'"''"'"' % ('"'"'/hdd2/code_zy/ATLOP/apex/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' egg_info --egg-base /tmp/pip-pip-egg-info-3awzykxh
cwd: /hdd2/code_zy/ATLOP/apex/
Preparing metadata (setup.py) ... error
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details
Please help me to explain the cause of the error and how to solve it (could it be a version problem, he stressed that it is a packbag problem, could it be a problem with apex source code?)
答案1
得分: 1
以下错误信息被打印出来:
正在处理 /hdd2/code_zy/ATLOP/apex
执行命令 python setup.py egg_info
回溯 (most recent call last):
文件 "<string>", 行 2, in <module>
文件 "<pip-setuptools-caller>", 行 34, in <module>
文件 "/hdd2/code_zy/ATLOP/apex/setup.py", 行 4, in <module>
from packaging.version import parse, Version
模块未找到错误: No module named 'packaging'
错误: 子进程退出并带有错误
这意味着 pip install
命令需要预先安装 packaging
包才能正确安装 apex
。
在安装 apex
之前先安装缺失的包:
pip install packaging
# 然后执行以下命令
git clone github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
packaging
包的 Pypi 页面链接:https://pypi.org/project/packaging/。
英文:
The following error is being printed:
Processing /hdd2/code_zy/ATLOP/apex
Running command python setup.py egg_info
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/hdd2/code_zy/ATLOP/apex/setup.py", line 4, in <module>
from packaging.version import parse, Version
ModuleNotFoundError: No module named 'packaging'
error: subprocess-exited-with-error
It means that the pip install
command needs the package packaging to be already installed to correctly install apex.
Install the missing package before installing apex:
pip install packaging
# Then, your commands
git clone github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
The link to the Pypi page of the packaging package: https://pypi.org/project/packaging/.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论