解决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_info
  Traceback (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, 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/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, 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,
      )
      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"))
  '"'"''"'"''"'"' % ('"'"'/home/glm/apex/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' egg_info --egg-base /tmp/pip-pip-egg-info-pijoox9c
  cwd: /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 ./

即可安装成功

相关推荐

  1. 华为NPU安装apex

    2024-06-14 08:54:01       17 阅读
  2. Linux排查-安装PHP的remi

    2024-06-14 08:54:01       21 阅读
  3. 《python》在用户包安装出现权限

    2024-06-14 08:54:01       9 阅读
  4. Linux安装Python3.11

    2024-06-14 08:54:01       10 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-14 08:54:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-14 08:54:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-14 08:54:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-14 08:54:01       20 阅读

热门阅读

  1. Ruby 条件判断

    2024-06-14 08:54:01       9 阅读
  2. 行为型模式-命令模式

    2024-06-14 08:54:01       8 阅读
  3. 怎么沉淀自己的价值——笔记

    2024-06-14 08:54:01       6 阅读
  4. 在windows机器上上架IOS苹果应用

    2024-06-14 08:54:01       10 阅读
  5. SQLite JDBC驱动程序

    2024-06-14 08:54:01       7 阅读
  6. sklearn、tensorflow、keras区别与联系--九五小庞

    2024-06-14 08:54:01       8 阅读
  7. 如何创建一个React组件并渲染到DOM中?

    2024-06-14 08:54:01       7 阅读
  8. 通用大模型与垂直大模型的博弈

    2024-06-14 08:54:01       7 阅读
  9. postman接口测试工具详解

    2024-06-14 08:54:01       7 阅读
  10. Http协议:Http缓存

    2024-06-14 08:54:01       7 阅读