【已解决】 error: subprocess-exited-with-error × python setup.py egg_info did not run successfully.

问题描述

        今天遇到这个问题:ImportError: cannot import name 'packaging' from 'pkg_resources' (/home/visionx/anaconda3/envs/gdem/lib/python3.8/site-packages/pkg_resources/__init__.py),其实这种问题很常见,希望给大家统一讲一下如何处理的,我们从头开始!

        具体描述为:

Collecting torch_sparse
  Using cached torch_sparse-0.6.18.tar.gz (209 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-mu4fnmkw/torch-sparse_7b1f67db8d584e36bedf832159648d4b/setup.py", line 11, in <module>
          from torch.utils.cpp_extension import (
        File "/home/visionx/anaconda3/envs/gdem/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 28, in <module>
          from pkg_resources import packaging  # type: ignore[attr-defined]
      ImportError: cannot import name 'packaging' from 'pkg_resources' (/home/visionx/anaconda3/envs/gdem/lib/python3.8/site-packages/pkg_resources/__init__.py)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
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.
(gdem) visionx@visionx:/media/visionx/monica/project24/GDEM$ pip install torch_sparse
Collecting torch_sparse
  Using cached torch_sparse-0.6.18.tar.gz (209 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-11nj3e0o/torch-sparse_e89b9d926f354738a403de89b0c3a695/setup.py", line 11, in <module>
          from torch.utils.cpp_extension import (
        File "/home/visionx/anaconda3/envs/gdem/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 28, in <module>
          from pkg_resources import packaging  # type: ignore[attr-defined]
      ImportError: cannot import name 'packaging' from 'pkg_resources' (/home/visionx/anaconda3/envs/gdem/lib/python3.8/site-packages/pkg_resources/__init__.py)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
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.

        看图: 

原因分析和解决

        1、在我的主页搜索torch

        2、结果如下,点击113这个

        3、选择这个网址https://pytorch-geometric.com/whl/

        4、选择对应版本安装,命令为:

pip install torch_sparse-0.6.18+pt21cu118-cp38-cp38-linux_x86_64.whl

        5、解决 

相关链接

Python Setup.py Egg_info Error Code (Solution) | Master Data Skills + AIWhile working with Python packages, programmers may encounter a specific error — 'python setup.py egg_info' failed with error code 1. This error is related to the package installation process and can arise due to several reasons, such as outdated or improperly installed pip or other package installation tools. You can fix the 'python setup.py egg_info'icon-default.png?t=N7T8https://blog.enterprisedna.co/python-setup-py-egg_info-error-code/https://pytorch-geometric.com/whl/torch-2.1.2%2Bcu118.htmlicon-default.png?t=N7T8https://pytorch-geometric.com/whl/torch-2.1.2%2Bcu118.html

完结撒花

        结束了,都结束了。

  • 22
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 错误:子进程以错误退出 × python setup.py egg_info未成功运行。 这个错误通常是由于缺少依赖项或安装包的问题导致的。您可以尝试检查您的环境和安装包是否正确,并重新运行命令。如果问题仍然存在,请查看错误消息的详细信息以获取更多帮助。 ### 回答2: 出现 "error: subprocess-exited-with-error × python setup.py egg_info did not run successfully." 通常是在安装 python 包时出现的问题。其中,“subprocess-exited-with-error” 的错误信息说明了子进程以错误的方式退出。而 "python setup.py egg_info" 是 python 包的安装程序。因此,出现此错误通常是由于以下原因之一: 1. Python 版本不兼容:某些程序或包只支持特定版本的 Python 。在尝试安装包时,你可能安装了一个不兼容的版本。因此,请检查 Python 版本是否与安装包的兼容以确保兼容。 2. 未安装所有依赖项:某些程序或包可能依赖于其他库或扩展程序。在安装包之前,请确保已经安装了所有所需的依赖项。 3. 缺少某些组件:出现此错误可能是由于某些缺少的组件或库。因此,在安装包之前,请先检查是否缺少某些组件或库,并在完成缺失组件的安装后重试安装包。 4. 已损坏或不完整的安装程序:在下载或安装软件包时,有时会遇到意外情况,例如网络连接错误或软件包文件本身已损坏。因此,请确保下载的软件包完整无损。 5. 在安装包时遇到其他错误:有时,此错误可能由其他问题引起。在这种情况下,您可能需要查找其他错误消息以找出问题的根本原因。 ### 回答3: 这个错误提示常见于 Python 中安装第三方包或模块时出现。通常是因为缺少必要的依赖项、网络不稳定以及其他错误引起的。下面我们就分别从以下几个方面来介绍解决该错误的方法。 1. 依赖项不足 在安装某些第三方包或模块时,一些依赖项可能会被要求安装。安装依赖项的方法有两种:一种是手动安装,即先按照提示下载依赖项,再进行安装;另一种是使用 pip 管理软件包。如果您使用的是类 Unix 系统(如 macOS 或 Linux),只需在终端中键入以下命令: ``` $ sudo apt-get install [package_name] ``` 如果您使用的是 Windows 系统,请安装必要的依赖项。 2. 网络问题 有时,网络不稳定或代理设置错误可能导致安装失败。在这种情况下,可以使用 Python 的 pip 指定代理服务器进行安装。例如: ``` $ pip install [package_name] --proxy=proxy_server ``` 3. 权限问题 在某些情况下,缺乏足够的权限可能会导致 Python 安装失败。例如,无法在根用户下进行操作,或者权限不足以访问安装目录。在这种情况下,我们可以通过更改文件夹的权限或使用管理员权限来解决该问题。如在 macOS 或 Linux 中,我们可以使用 chmod 命令更改文件夹权限: ``` $ chmod 777 [folder_name] ``` 如果您使用的是 Windows 系统,请确保在管理员权限下进行操作。 以上是解决 Python 安装时可能出现的 subprocess-exited-with-error 错误的几种方法。当然,在敲击命令前先进行一些基本的诊断(例如检查 Python 版本、检查安装目录是否正确等)是非常必要的。希望此文能够帮到您。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值