【问题标题】:Error while installing PyTorch using pip - cannot build wheel使用 pip 安装 PyTorch 时出错 - 无法构建轮子
【发布时间】:2020-11-04 12:13:53
【问题描述】:

当我尝试运行 pip3 install pytorchpip install pytorch 时得到以下输出

Collecting pytorch
  Using cached pytorch-1.0.2.tar.gz (689 bytes)
Building wheels for collected packages: pytorch
  Building wheel for pytorch (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/chaitanya/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3v4wd97t/pytorch/setup.py'"'"'; __file__='"'"'/tmp/pip-install-3v4wd97t/pytorch/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-8rsdyb8e
       cwd: /tmp/pip-install-3v4wd97t/pytorch/
  Complete output (5 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-3v4wd97t/pytorch/setup.py", line 15, in <module>
      raise Exception(message)
  Exception: You tried to install "pytorch". The package named for PyTorch is "torch"
  ----------------------------------------
  ERROR: Failed building wheel for pytorch
  Running setup.py clean for pytorch
Failed to build pytorch
Installing collected packages: pytorch
    Running setup.py install for pytorch ... error
    ERROR: Command errored out with exit status 1:
     command: /home/chaitanya/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3v4wd97t/pytorch/setup.py'"'"'; __file__='"'"'/tmp/pip-install-3v4wd97t/pytorch/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-eld9j0g4/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/chaitanya/.local/include/python3.8/pytorch
         cwd: /tmp/pip-install-3v4wd97t/pytorch/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-3v4wd97t/pytorch/setup.py", line 11, in <module>
        raise Exception(message)
    Exception: You tried to install "pytorch". The package named for PyTorch is "torch"
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/chaitanya/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3v4wd97t/pytorch/setup.py'"'"'; __file__='"'"'/tmp/pip-install-3v4wd97t/pytorch/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-eld9j0g4/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/chaitanya/.local/include/python3.8/pytorch Check the logs for full command output.

我从here 下载了匹配的轮子,但我不知道如何处理它。如果需要,我的 Python 安装正在使用 anaconda3。我应该从这里做什么?关于如何自己解决此问题的提示也将不胜感激。

【问题讨论】:

    标签: python python-3.x linux pip pytorch


    【解决方案1】:

    根据您的错误:

    Exception: You tried to install "pytorch". The package named for PyTorch is "torch"

    它告诉你你需要知道什么,而不是

    pip install pytorch
    

    应该是

    pip install torch
    

    我从这里下载了匹配的轮子,但我不知道如何处理它

    安装.whl 文件就这么简单

    pip install <path to .whl file>
    

    我的 Python 安装使用的是 anaconda3

    这是非常相关的。您通常应该尽可能避免在您的 conda 环境中使用pip。相反,您可以从 pytroch.org 找到正确的 conda install 命令,用于您的设置(cuda 版本等),例如对于 cuda 11 它会是

    conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch
    

    【讨论】:

    • 谢谢。我会试试这个然后回到这里。
    • 使用 conda 的安装导致NotWritableError,即用户在此路径上没有写入权限,并且 sudo 不能与 conda 一起使用,从我收集到的问题之一他们的github。我唯一的出路是完全重新安装 Python3 吗?
    • 你检查过anaconda文件夹的权限吗,可能没有正确设置
    猜你喜欢
    • 2020-08-02
    • 1970-01-01
    • 2021-05-23
    • 2016-04-04
    • 1970-01-01
    • 2019-08-05
    • 2020-03-19
    • 1970-01-01
    • 2019-12-21
    相关资源
    最近更新 更多