本文主要是介绍解决linux下安装apex库报错:ModuleNotFoundError: No module named ‘packaging‘,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
使用如下命令安装apex:
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
报错:
Running command python setup.py egg_infoTraceback (most recent call last):File "<string>", line 2, in <module>File "<pip-setuptools-caller>", line 34, in <module>File "/home/glm/apex/setup.py", line 4, in <module>from packaging.version import parse, VersionModuleNotFoundError: 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/letrain/miniconda/envs/glm/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, tokenizetry:import setuptoolsexcept ImportError as error:print("ERROR: Can not execute `setup.py` since setuptools is not available in ""the build environment.",file=sys.stderr,)sys.exit(1)__file__ = %rsys.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"))'"'"''"'"''"'"' % ('"'"'/home/glm/apex/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' egg_info --egg-base /tmp/pip-pip-egg-info-pijoox9ccwd: /home/glm/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.
在安装命令中加入--no-build-isolation,使用如下命令:
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" --no-build-isolation ./
即可安装成功
这篇关于解决linux下安装apex库报错:ModuleNotFoundError: No module named ‘packaging‘的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!