2

I'm trying to run this https://github.com/shariqiqbal2810/MAAC repository and it has a module called torch

import torch as McLawrence
from torch.autograd import Variable

I'm using python version 3.7.1 and I downgraded to 3.6.5 on win10 I tried to use

pip install torch
pip install pytorch
pip install torchvision

I change torch to pytorch

I enter their website https://pytorch.org/ and I tried all suggestion that uses pip such as

pip3 install https://download.pytorch.org/whl/cu80/torch-1.0.0-cp36-cp36m-win_amd64.whl
pip3 install torchvision

I read every comment relate to this issue in

https://github.com/pytorch/pytorch/issues/566

I read most of the answer here

https://stackoverflow.com/search?q=module+named+torch

But I still get the same message:

Collecting torch
  Using cached https://files.pythonhosted.org/packages/5f/e9/bac4204fe9cb1a002ec6140b47f51affda1655379fe302a1caef421f9846/torch-0.1.2.post1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\iibra\AppData\Local\Temp\pip-install-yupbt_qk\torch\setup.py", line 11, in <module>
        raise RuntimeError(README)
    RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566).

    Please follow the instructions at http://pytorch.org/ to install with miniconda instead.

pip install pytorch
Collecting pytorch
  Using cached https://files.pythonhosted.org/packages/a9/41/4487bc23e3ac4d674943176f5aa309427b011e00607eb98899e9d951f67b/pytorch-0.1.2.tar.gz
Building wheels for collected packages: pytorch
  Running setup.py bdist_wheel for pytorch ... error
  Complete output from command c:\users\iibra\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\iibra\\AppData\\Local\\Temp\\pip-install-7qwe1571\\pytorch\\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 C:\Users\iibra\AppData\Local\Temp\pip-wheel-_mjh_olk --python-tag cp36:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\iibra\AppData\Local\Temp\pip-install-7qwe1571\pytorch\setup.py", line 17, in <module>
      raise Exception(message)
  Exception: You should install pytorch from http://pytorch.org



pip install torchvision
Collecting torchvision
  Using cached https://files.pythonhosted.org/packages/ca/0d/f00b2885711e08bd71242ebe7b96561e6f6d01fdb4b9dcf4d37e2e13c5e1/torchvision-0.2.1-py2.py3-none-any.whl
Requirement already satisfied: six in c:\users\iibra\appdata\local\programs\python\python36\lib\site-packages (from torchvision) (1.11.0)
Requirement already satisfied: pillow>=4.1.1 in c:\users\iibra\appdata\local\programs\python\python36\lib\site-packages (from torchvision) (5.1.0)
Collecting torch (from torchvision)
  Using cached https://files.pythonhosted.org/packages/5f/e9/bac4204fe9cb1a002ec6140b47f51affda1655379fe302a1caef421f9846/torch-0.1.2.post1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\iibra\AppData\Local\Temp\pip-install-k8dl2vhz\torch\setup.py", line 11, in <module>
        raise RuntimeError(README)
    RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566).

    Please follow the instructions at http://pytorch.org/ to install with miniconda instead.
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
I_Al-thamary
  • 3,385
  • 2
  • 24
  • 37
  • Try this: First, uninstall then clear pip cache then install wheels with `--no-deps` option. – kHarshit Jan 20 '19 at 07:48
  • @harshit_k I tried to `pip cache ` `ERROR: unknown command "cache" - maybe you meant "check"` https://github.com/pypa/pip/issues/4830 https://github.com/pypa/pip/issues/4685 – I_Al-thamary Jan 20 '19 at 09:39
  • Ya, I meant to remove the cache. Do this: `rm -rf ~/.cache/pip` to remove cache from pip or simply go the folder `.cache` and delete the pip folder. Check this https://stackoverflow.com/questions/9510474/removing-pips-cache – kHarshit Jan 20 '19 at 09:41
  • You mean `pip/cache`. – I_Al-thamary Jan 20 '19 at 09:48
  • Check the second answer from the link I shared above. The reason I'm saying this is because looking at the errors it seems pip is using cached torch as mentioned https://github.com/pytorch/pytorch/issues/566#issuecomment-302721953. Then install pytorch wheels with `--no deps`. – kHarshit Jan 20 '19 at 09:52
  • 1
    Thanks, it worked `pip3 --no-cache-dir install https://download.pytorch.org/whl/cu80/torch-1.0.0-cp36-cp36m-win_amd64.whl` – I_Al-thamary Jan 20 '19 at 09:52
  • Great, Also, you can write this as answer and accept it or do you want me to do that? – kHarshit Jan 20 '19 at 09:59
  • 1
    @harshit_k you can do it, I would not be able to solve it without your comment. – I_Al-thamary Jan 20 '19 at 10:05

2 Answers2

4

Installing from the PyTorch wheel should have worked. But, the problem turns out to be that pip is using the cached pytorch to install it as mentioned on GitHub here.

Collecting pytorch
  Using cached https://files.pythonhosted.org/packages...

Either removing the pip's cache from %LocalAppData%\pip\Cache on Windows or disabling it by using --no-cache-dir would solve the issue as follows:

pip3 --no-cache-dir install https://download.pytorch.org/whl/cu80/torch-1.0.0-cp36-cp36m-win_amd64.whl
kHarshit
  • 11,362
  • 10
  • 52
  • 71
2

For smooth installation of PyTorch, use their options selector, on PyTorch landing page: https://pytorch.org/ Then copy and run the pip command (or other) according to their suggestion.

enter image description here