3

I am trying to install pytorch with pip using

pip install torch

or

pip3 install torch===1.3.1 torchvision===0.4.2 -f https://download.pytorch.org/whl/torch_stable.html

with python 3.7.4

and with python 3.8 (latest stable release)

both on 32 and 64 bit.

and getting

Collecting torch   Using cached
https://files.pythonhosted.org/packages/f8/02/880b468bd382dc79896eaecbeb8ce95e9c4b99a24902874a2cef0b562cea/torch-0.1.2.post2.tar.gz
Collecting pyyaml (from torch)   Downloading
https://files.pythonhosted.org/packages/bc/3f/4f733cd0b1b675f34beb290d465a65e0f06b492c00b111d1b75125062de1/PyYAML-5.1.2-cp37-cp37m-win_amd64.whl
(215kB)
    100% |████████████████████████████████| 225kB 1.2MB/s Installing collected packages: pyyaml, torch   Running setup.py install for torch
... error
    Complete output from command C:\Noam\Code\threadart\stav-rl\venv\Scripts\python.exe -u -c "import
setuptools,
tokenize;__file__='C:\\Users\\noams\\AppData\\Local\\Temp\\pip-install-djc6s2t8\\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 C:\Users\noams\AppData\Local\Temp\pip-record-zohv2zo7\install-record.txt
--single-version-externally-managed --compile --install-headers C:\Noam\Code\threadart\stav-rl\venv\inclu de\site\python3.7\torch:
    running install
    running build_deps
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\noams\AppData\Local\Temp\pip-install-djc6s2t8\torch\setup.py",
line 265, in <module>
        description="Tensors and Dynamic neural networks in Python with strong GPU acceleration",
      File "C:\Noam\Code\threadart\stav-rl\venv\lib\site-packages\setuptools-40.8.0-py3.7.egg\setuptools\__init__.py",
line 145, in setup
      File "C:\Python37_x64\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Python37_x64\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:\Python37_x64\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\noams\AppData\Local\Temp\pip-install-djc6s2t8\torch\setup.py",
line 99, in run
        self.run_command('build_deps')
      File "C:\Python37_x64\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Python37_x64\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\noams\AppData\Local\Temp\pip-install-djc6s2t8\torch\setup.py",
line 51, in run
        from tools.nnwrap import generate_wrappers as generate_nn_wrappers
    ModuleNotFoundError: No module named 'tools.nnwrap'

    ---------------------------------------- Command "C:\Noam\Code\threadart\stav-rl\venv\Scripts\python.exe -u -c "import
setuptools,
tokenize;__file__='C:\\Users\\noams\\AppData\\Local\\Temp\\pip-install-djc6s2t8\\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
C:\Users\noams\AppData\Local\Temp\pip-record-zohv2zo7\install-record.txt
--single-version-externally-managed --compile --install-headers C:\Noam\Code\threadart\stav-rl\venv\include\site\python3.7\torch" 
failed with error code 1 in
C:\Users\noams\AppData\Local\Temp\pip-install-djc6s2t8\torch\

clearly, I am doing something wrong.

Please help!

3 Answers 3

4

I had the same problem. Now the problem is fixed. (2020-05-31)

  1. Visited the site pytorch.org
  2. and find "QUICK START LOCALLY" on homepage of pytorch.org. ( it' can find by scroll down little )
  3. Checking the environment form of your system (ex: Windows, pip, python, ,,) then, you can see the install command. "pip install torch===.... "

  4. Copy the install command

  5. and Execute the command at your system.

Good Luck !!

Sign up to request clarification or add additional context in comments.

Comments

1

Use the below commands if you have no GPU (only for CPU):

  • version 1.2: conda install pytorch==1.2.0 torchvision==0.4.0 cpuonly -c pytorch

  • for new version: conda install pytorch torchvision cpuonly -c pytorch

or

Use the below commands if you have GPU(use your own CUDA version):

  • version 1.2: conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch

  • for new version: conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

it might be better to use anaconda command prompt for install pytorch and if possible use python 3.6. its more suitable. python 3.6 is more stable for using open source libraries. Also you can find installing process in below link if needed, https://medium.com/@bryant.kou/how-to-install-pytorch-on-windows-step-by-step-cc4d004adb2a

if you need to setup these with pip only, you may try it

for python 3.6:

pip install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp36-cp36m- win_amd64.whl
pip install torchvision

for python 3.7:

pip install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp37-cp37m-win_amd64.whl
pip install torchvision

i think Conda is better option instead of pip in open source libraries installation

Comments

0

If you are using Anaconda (3.7) in windows then you need to install via .whl file.

Download .whl file from here:- https://download.pytorch.org/whl/torch_stable.html

then put in the working directory and install it using pip, for my system I have renamed anaconda's pip to pip37

pip37 install torch-1.5.1+cpu-cp37-cp37m-win_amd64.whl
pip37 install torchvision-0.6.1+cpu-cp37-cp37m-win_amd64.whl

It will install Torch 1.5 & Torchvision 0.6.1 in your anaconda environment

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.