【问题标题】:RuntimeError: PyTorch does not currently provide packages for PyPIRuntimeError:PyTorch 目前不提供 PyPI 包
【发布时间】:2020-06-29 01:46:33
【问题描述】:

我正在尝试运行这个 https://github.com/shariqiqbal2810/MAAC 存储库,它有一个名为 torch 的模块

import torch as McLawrence
from torch.autograd import Variable

我正在使用python版本3.7.1,我在win10上降级到3.6.5 我尝试使用

pip install torch
pip install pytorch
pip install torchvision

我把torch改成pytorch

我进入他们的网站https://pytorch.org/ 并尝试了所有使用pip 的建议,例如

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

我阅读了与此问题相关的每条评论

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

我在这里阅读了大部分答案

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

但我仍然收到相同的消息:

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.

【问题讨论】:

  • 试试这个:首先,卸载然后清除 pip 缓存,然后使用 --no-deps 选项安装轮子。
  • @harshit_k 我试过pip cache ERROR: unknown command "cache" - maybe you meant "check"github.com/pypa/pip/issues/4830github.com/pypa/pip/issues/4685
  • 是的,我的意思是删除缓存。这样做:rm -rf ~/.cache/pip 从 pip 中删除缓存,或者直接转到文件夹 .cache 并删除 pip 文件夹。检查这个stackoverflow.com/questions/9510474/removing-pips-cache
  • 谢谢,它成功了pip3 --no-cache-dir install https://download.pytorch.org/whl/cu80/torch-1.0.0-cp36-cp36m-win_amd64.whl
  • @harshit_k 你可以做到,没有你的评论我无法解决。

标签: python pytorch torch


【解决方案1】:

从 PyTorch 轮子安装应该可以工作。但是,问题是 pip 使用缓存的 pytorch 来安装它,如 GitHub here 所述。

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

在 Windows 上 removing 来自 %LocalAppData%\pip\Cache 的 pip 缓存或使用 --no-cache-dir 禁用它可以解决以下问题:

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

【讨论】:

【解决方案2】:

为了顺利安装 PyTorch,请在 PyTorch 登录页面上使用他们的选项选择器: https://pytorch.org/ 然后根据他们的建议复制并运行 pip 命令(或其他命令)。

【讨论】:

  • 我在问题中提到我已经使用了所有与pip相关的推荐。
猜你喜欢
  • 2018-05-09
  • 2015-01-09
  • 2020-06-09
  • 1970-01-01
  • 2018-08-14
  • 2020-06-21
  • 2011-02-28
  • 2022-08-09
  • 2019-09-06
相关资源
最近更新 更多