Error while installing PyTorch using pip - cannot build wheel
I get the following output when I try to run pip3 install pytorch or pip 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] = '&quot;'&quot;'/tmp/pip-install-3v4wd97t/pytorch/setup.py'&quot;'&quot;'; __file__='&quot;'&quot;'/tmp/pip-install-3v4wd97t/pytorch/setup.py'&quot;'&quot;';f=getattr(tokenize, '&quot;'&quot;'open'&quot;'&quot;', open)(__file__);code=f.read().replace('&quot;'&quot;'\r\n'&quot;'&quot;', '&quot;'&quot;'\n'&quot;'&quot;');f.close();exec(compile(code, __file__, '&quot;'&quot;'exec'&quot;'&quot;'))' bdist_wheel -d /tmp/pip-wheel-8rsdyb8e
       cwd: /tmp/pip-install-3v4wd97t/pytorch/
  Complete output (5 lines):
  Traceback (most recent call last):
    File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;/tmp/pip-install-3v4wd97t/pytorch/setup.py&quot;, line 15, in &lt;module&gt;
      raise Exception(message)
  Exception: You tried to install &quot;pytorch&quot;. The package named for PyTorch is &quot;torch&quot;
  ----------------------------------------
  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] = '&quot;'&quot;'/tmp/pip-install-3v4wd97t/pytorch/setup.py'&quot;'&quot;'; __file__='&quot;'&quot;'/tmp/pip-install-3v4wd97t/pytorch/setup.py'&quot;'&quot;';f=getattr(tokenize, '&quot;'&quot;'open'&quot;'&quot;', open)(__file__);code=f.read().replace('&quot;'&quot;'\r\n'&quot;'&quot;', '&quot;'&quot;'\n'&quot;'&quot;');f.close();exec(compile(code, __file__, '&quot;'&quot;'exec'&quot;'&quot;'))' 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 &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
      File &quot;/tmp/pip-install-3v4wd97t/pytorch/setup.py&quot;, line 11, in &lt;module&gt;
        raise Exception(message)
    Exception: You tried to install &quot;pytorch&quot;. The package named for PyTorch is &quot;torch&quot;
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/chaitanya/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '&quot;'&quot;'/tmp/pip-install-3v4wd97t/pytorch/setup.py'&quot;'&quot;'; __file__='&quot;'&quot;'/tmp/pip-install-3v4wd97t/pytorch/setup.py'&quot;'&quot;';f=getattr(tokenize, '&quot;'&quot;'open'&quot;'&quot;', open)(__file__);code=f.read().replace('&quot;'&quot;'\r\n'&quot;'&quot;', '&quot;'&quot;'\n'&quot;'&quot;');f.close();exec(compile(code, __file__, '&quot;'&quot;'exec'&quot;'&quot;'))' 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.

I downloaded the matching wheel from here, but am couldn't figure out what to do with it. My Python installation is using anaconda3, if that's needed. What should I do from here? Tips on how I could have resolved this on my own would also be appreciated.

From your error:

Exception: You tried to install &quot;pytorch&quot;. The package named for PyTorch is &quot;torch&quot;

which tells you what you need to know, instead of
pip install pytorch

it should be
pip install torch


I downloaded the matching wheel from here, but am couldn't figure out what to do with it

Installing .whl files is as easy as
pip install &lt;path to .whl file&gt;


My Python installation is using anaconda3

That is very relevant. You should generally avoid as much as possible to use pip in your conda environment. Instead, you can find the correct conda install command for your setup(cuda version etc.) from pytroch.org, e.g. for cuda 11 it would be
conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch

