在macOS下使用pip安装pytorch失败

时间:2019-02-13 03:50:02

标签: macos pip install pytorch

当我使用pip安装pytorch时,出现了一些异常。

Env:

  1. 系统:MaxOS High Sierra
  2. python版本:3.6
  3. 点子版本:19.0.2

输入:pip install pytorch

输出:

Collecting pytorch
  Using cached https://files.pythonhosted.org/packages/a9/41/4487bc23e3ac4d674943176f5aa309427b011e00607eb98899e9d951f67b/pytorch-0.1.2.tar.gz
Building wheels for collected packages: pytorch
  Building wheel for pytorch (setup.py) ... error
  Complete output from command /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/lw/s7b4_22d1v30nfm0wkys878w0000gn/T/pip-install-ygd1rucx/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 /private/var/folders/lw/s7b4_22d1v30nfm0wkys878w0000gn/T/pip-wheel-p0npaj5r --python-tag cp36:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/lw/s7b4_22d1v30nfm0wkys878w0000gn/T/pip-install-ygd1rucx/pytorch/setup.py", line 17, in <module>
      raise Exception(message)
  Exception: You should install pytorch from http://pytorch.org

  ----------------------------------------
  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
    Complete output from command /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/lw/s7b4_22d1v30nfm0wkys878w0000gn/T/pip-install-ygd1rucx/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 /private/var/folders/lw/s7b4_22d1v30nfm0wkys878w0000gn/T/pip-record-us45ly0z/install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/lw/s7b4_22d1v30nfm0wkys878w0000gn/T/pip-install-ygd1rucx/pytorch/setup.py", line 13, in <module>
        raise Exception(message)
    Exception: You should install pytorch from http://pytorch.org

    ----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/lw/s7b4_22d1v30nfm0wkys878w0000gn/T/pip-install-ygd1rucx/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 /private/var/folders/lw/s7b4_22d1v30nfm0wkys878w0000gn/T/pip-record-us45ly0z/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/lw/s7b4_22d1v30nfm0wkys878w0000gn/T/pip-install-ygd1rucx/pytorch/

1 个答案:

答案 0 :(得分:0)

您正在PyPI上安装名为pytorch的旧软件包,即pytorch 0.1.2。这就是为什么您收到例外。

您应该从pytorch website安装它。您可以在其中选择系统配置,并提供安装命令。另外,最新版本的pytorch在PyPI上名为torch。所以,只要

pip3 install torch  # or with pip

如果由于缓存失败,请尝试使用-no-cache-dir选项。