简体   繁体   中英

Under macOS using pip install pytorch failure

When I'm using pip to install pytorch, some exception appeared.

Env:

  1. Sys: MaxOS High Sierra
  2. python version : 3.6
  3. pip version : 19.0.2

input: pip install pytorch

output:

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/

You're installing an old package named pytorch on PyPI ie pytorch 0.1.2. That's why you're receiving the exception.

You're supposed to install it from the pytorch website . There you'll an option to select your system configuration, it'll give you the command to install it. Also, the latest version of pytorch is named torch on PyPI. So, just do

pip3 install torch  # or with pip

If it fails due to cache, try with -no-cache-dir option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM