Pytorch installation on windows
I have tried many suggestions online to install in my virtual env "torch" but to no avail. It won't let me import torch. I am able to install torchvision through conda though following this link: https://pytorch.org/get-started/locally/. Any suggestions are welcome!

Here is the error message (I downgrade to python 3.5 in the virtualenv)

(env_peem) PS E:\Users\Maggie\TS_MatSeg_Share&gt; pip install torch
Collecting torch\Users\Maggie\TS_MatSeg_Share&gt;
  Using cached torch-0.1.2.post2.tar.gz (128 kB)
Requirement already satisfied: pyyaml in e:\users\maggie\ts_matseg_share\env_peem\lib\site-packages (from torch) (5.3.1)
Building wheels for collected packages: torch
  Building wheel for torch (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'E:\Users\Maggie\TS_MatSeg_Share\env_peem\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'E:\\Users\\Maggie\\AppData\\Local\\Temp\\7\\pip-install-80ts7bt9\\torch\\setup.py'"'"'; __file__='"'"'E:\\Users\\Maggie\\AppData\\Local\\Temp\\7\\pip-install-80ts7bt9\\torch\\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 'E:\Users\Maggie\AppData\Local\Temp\7\pip-wheel-xn9ld0bu'
       cwd: E:\Users\Maggie\AppData\Local\Temp\7\pip-install-80ts7bt9\torch\
  Complete output (30 lines):
  running bdist_wheel
  running build
  running build_deps
  Traceback (most recent call last):
    File "&lt;string&gt;", line 1, in &lt;module&gt;
    File "E:\Users\Maggie\AppData\Local\Temp\7\pip-install-80ts7bt9\torch\setup.py", line 265, in &lt;module&gt;
      description="Tensors and Dynamic neural networks in Python with strong GPU acceleration",
    File "E:\Users\Maggie\TS_MatSeg_Share\env_peem\lib\site-packages\setuptools\__init__.py", line 144, in setup
      return distutils.core.setup(**attrs)
    File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "E:\Users\Maggie\TS_MatSeg_Share\env_peem\lib\site-packages\wheel\bdist_wheel.py", line 223, in run
      self.run_command('build')
    File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "E:\Users\Maggie\AppData\Local\Temp\7\pip-install-80ts7bt9\torch\setup.py", line 51, in run
      from tools.nnwrap import generate_wrappers as generate_nn_wrappers
  ImportError: No module named 'tools.nnwrap'
  ----------------------------------------
  ERROR: Failed building wheel for torch
  Running setup.py clean for torch
  ERROR: Command errored out with exit status 1:
   command: 'E:\Users\Maggie\TS_MatSeg_Share\env_peem\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'E:\\Users\\Maggie\\AppData\\Local\\Temp\\7\\pip-install-80ts7bt9\\torch\\setup.py'"'"'; __file__='"'"'E:\\Users\\Maggie\\AppData\\Local\\Temp\\7\\pip-install-80ts7bt9\\torch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' clean --all
       cwd: E:\Users\Maggie\AppData\Local\Temp\7\pip-install-80ts7bt9\torch
  Complete output (2 lines):
  running clean
  error: [Errno 2] No such file or directory: '.gitignore'
  ----------------------------------------
  ERROR: Failed cleaning build dir for torch
Failed to build torch
Installing collected packages: torch
    Running setup.py install for torch ... error
    ERROR: Command errored out with exit status 1:
     command: 'E:\Users\Maggie\TS_MatSeg_Share\env_peem\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'E:\\Users\\Maggie\\AppData\\Local\\Temp\\7\\pip-install-80ts7bt9\\torch\\setup.py'"'"'; __file__='"'"'E:\\Users\\Maggie\\AppData\\Local\\Temp\\7\\pip-install-80ts7bt9\\torch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'E:\Users\Maggie\AppData\Local\Temp\7\pip-record-z6gt4ig9\install-record.txt' --single-version-externally-managed --compile --install-headers 'E:\Users\Maggie\TS_MatSeg_Share\env_peem\include\site\python3.5\torch'
         cwd: E:\Users\Maggie\AppData\Local\Temp\7\pip-install-80ts7bt9\torch\
    Complete output (23 lines):
    running install
    running build_deps
    Traceback (most recent call last):
      File "&lt;string&gt;", line 1, in &lt;module&gt;
      File "E:\Users\Maggie\AppData\Local\Temp\7\pip-install-80ts7bt9\torch\setup.py", line 265, in &lt;module&gt;
        description="Tensors and Dynamic neural networks in Python with strong GPU acceleration",
      File "E:\Users\Maggie\TS_MatSeg_Share\env_peem\lib\site-packages\setuptools\__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "E:\Users\Maggie\AppData\Local\Temp\7\pip-install-80ts7bt9\torch\setup.py", line 99, in run
        self.run_command('build_deps')
      File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Maggie\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "E:\Users\Maggie\AppData\Local\Temp\7\pip-install-80ts7bt9\torch\setup.py", line 51, in run
        from tools.nnwrap import generate_wrappers as generate_nn_wrappers
    ImportError: No module named 'tools.nnwrap'
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'E:\Users\Maggie\TS_MatSeg_Share\env_peem\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'E:\\Users\\Maggie\\AppData\\Local\\Temp\\7\\pip-install-80ts7bt9\\torch\\setup.py'"'"'; __file__='"'"'E:\\Users\\Maggie\\AppData\\Local\\Temp\\7\\pip-install-80ts7bt9\\torch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'E:\Users\Maggie\AppData\Local\Temp\7\pip-record-z6gt4ig9\install-record.txt' --single-version-externally-managed --compile --install-headers 'E:\Users\Maggie\TS_MatSeg_Share\env_peem\include\site\python3.5\torch' Check the logs for full command output.


It tries to install torch-0.1.2.post2.tar.gz, which is an extremely outdated version, and it probably was more involved to install it back then. You don't want that version, but rather the most recent one, which currently is 1.5.0.

You didn't select the appropriate configuration from PyTorch - Getting Started Locally, because if you select Windows, which is the operating system you are using, the installation command is:

pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html


That is because PyTorch does not publish the Windows versions to PyPI anymore, and it needs to be installed from their custom registry.
