Installing Pytorch with pip fails

Hello everyone! I am trying to install Pytorch with pip ( I want to create a Unity ML agents environment) and it fails. I tried:

(venv) C:\Users\Alexandra\Documents\Unity ML agents_first>pip install torch===1.7.1+cu110 torchvision===0.8.2+cu110 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html
ERROR: Could not find a version that satisfies the requirement torch===1.7.1+cu110
ERROR: No matching distribution found for torch===1.7.1+cu110

and also simply :

(venv) C:\Users\Alexandra\Documents\Unity ML agents_first>pip install torch
Collecting torch
  Using cached torch-0.1.2.post2.tar.gz (128 kB)
Requirement already satisfied: pyyaml in c:\users\alexandra\documents\unity ml agents_first\venv\lib\site-packages (from torch) (5.4.1)
WARNING: The candidate selected for download or install is a yanked version: 'torch' candidate (version 0.1.2.post2 at https://files.pythonhosted.org/packages/f8/02/880b468bd382dc79896eaecbeb8ce95e9c4b99a24902874a2cef0b562cea/torch-0.1.2.post2.tar.gz#sha256=a43e37f8f927c5b18f80cd163daaf6a1920edafcab5102e02e3e14bb97d9c874 (from https://pypi.org/simple/torch/))
Reason for being yanked: 0.1.2 is past it's support date and confuses users on unsupported platforms
Using legacy 'setup.py install' for torch, since package 'wheel' is not installed.
Installing collected packages: torch
    Running setup.py install for torch ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\alexandra\documents\unity ml agents_first\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Alexandra\\AppData\\Local\\Temp\\pip-install-n1q74mey\\torch_1eaaa35250fe429f91804a5735444e40\\setup.py'"'"'; __file__='"'"'C:\\Users\\Alexandra\\AppData\\Local\\Temp\\pip-install-n1q74mey\\torch_1eaaa35250fe429f91804a5735444e40\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Alexandra\AppData\Local\Temp\pip-record-2ocx9o87\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\alexandra\documents\unity ml agents_first\venv\include\site\python3.8\torch'
         cwd: C:\Users\Alexandra\AppData\Local\Temp\pip-install-n1q74mey\torch_1eaaa35250fe429f91804a5735444e40\
    Complete output (23 lines):
    running install
    running build_deps
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Alexandra\AppData\Local\Temp\pip-install-n1q74mey\torch_1eaaa35250fe429f91804a5735444e40\setup.py", line 225, in <module>
        setup(name="torch", version="0.1.2.post2",
      File "c:\users\alexandra\documents\unity ml agents_first\venv\lib\site-packages\setuptools\__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "C:\Users\Alexandra\AppData\Local\Programs\Python\Python38-32\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\Alexandra\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:\Users\Alexandra\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\Alexandra\AppData\Local\Temp\pip-install-n1q74mey\torch_1eaaa35250fe429f91804a5735444e40\setup.py", line 99, in run
        self.run_command('build_deps')
      File "C:\Users\Alexandra\AppData\Local\Programs\Python\Python38-32\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Alexandra\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\Alexandra\AppData\Local\Temp\pip-install-n1q74mey\torch_1eaaa35250fe429f91804a5735444e40\setup.py", line 51, in run
        from tools.nnwrap import generate_wrappers as generate_nn_wrappers
    ModuleNotFoundError: No module named 'tools.nnwrap'
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\alexandra\documents\unity ml agents_first\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Alexandra\\AppData\\Local\\Temp\\pip-install-n1q74mey\\torch_1eaaa35250fe429f91804a5735444e40\\setup.py'"'"'; __file__='"'"'C:\\Users\\Alexandra\\AppData\\Local\\Temp\\pip-install-n1q74mey\\torch_1eaaa35250fe429f91804a5735444e40\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Alexandra\AppData\Local\Temp\pip-record-2ocx9o87\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\alexandra\documents\unity ml agents_first\venv\include\site\python3.8\torch' Check the logs for full command output.

I also tried to use pip3 but it gives me the same errors. I am using Python 3.8.6 on Windows 10 (64 bit) . Does anyone have any suggestions on how to solve this, or any workaround to be able to use Unity ML agents?

Thank you!
A.

I think the triple equal === should be double equal ==.
I’ll try to ping the PyTorch team about it.

@tom Triple equal is not fully equivalent with double equal. For example, with ===1.7.1 we will get the package version with 1.7.1. But with ==1.7.1, you may get any one of the following version: 1.7.1, 1.7.1+cpu, 1.7.1+cu101, 1.7.1+cu102, 1.7.1+cu110. More details can be seen in PEP 440. Here we use triple equality signs on purpose, so this is not a bug.

@Alex_Dima The path C:\Users\Alexandra\AppData\Local\Programs\Python\Python38-32 can be seen in the log. The 64-bit Python is not used. If you are sure python refers to x64 Python distribution, then you can do python -m pip install torch===1.7.1+cu110 torchvision===0.8.2+cu110 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html.

1 Like

@peterjc123 Thank you for correcting me!