I got this error when installing PyTorch in Pycharm. I installed torchvision and torch successfully but the problem is in PyTorch
I try to install PyTorch in cmd to import it in pycharm project. it gives me numerous errors after Running setup.py install for PyTorch ... error.
ERROR: Command errored out with exit status 1:
     command: 'c:\users\sarah\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '&quot;'&quot;'C:\\Users\\sarah\\AppData\\Local\\Temp\\pip-install-uejad0d4\\pytorch_87cb825d32c24f6ca6f350ea09c367a4\\setup.py'&quot;'&quot;'; __file__='&quot;'&quot;'C:\\Users\\sarah\\AppData\\Local\\Temp\\pip-install-uejad0d4\\pytorch_87cb825d32c24f6ca6f350ea09c367a4\\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 'C:\Users\sarah\AppData\Local\Temp\pip-record-k6l1ba85\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\sarah\AppData\Roaming\Python\Python38\Include\PyTorch'
         cwd: C:\Users\sarah\AppData\Local\Temp\pip-install-uejad0d4\pytorch_87cb825d32c24f6ca6f350ea09c367a4\
    Complete output (5 lines):
    Traceback (most recent call last):
      File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
      File &quot;C:\Users\sarah\AppData\Local\Temp\pip-install-uejad0d4\pytorch_87cb825d32c24f6ca6f350ea09c367a4\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: 'c:\users\sarah\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '&quot;'&quot;'C:\\Users\\sarah\\AppData\\Local\\Temp\\pip-install-uejad0d4\\pytorch_87cb825d32c24f6ca6f350ea09c367a4\\setup.py'&quot;'&quot;'; __file__='&quot;'&quot;'C:\\Users\\sarah\\AppData\\Local\\Temp\\pip-install-uejad0d4\\pytorch_87cb825d32c24f6ca6f350ea09c367a4\\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 'C:\Users\sarah\AppData\Local\Temp\pip-record-k6l1ba85\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\sarah\AppData\Roaming\Python\Python38\Include\PyTorch' Check the logs for full command output.


The best way to install PyTorch is using pip or conda, with the commands provided on their website: https://pytorch.org/
This way you can choose which OS you are using, which version of CUDA (or no CUDA), and whether you are using conda or pip.
Please notice that as of today (12/14/20), I tried installing PyTorch in a new environment and it failed because of a new Numpy version. I solved this by installing Numpy first:
pip install numpy==1.18

And then PyTorch as usual from their website. Notice that their pip install command specifies torch as the package name and not pytorch, which you seem to have used.
