PyCharm无法安装PyTorch-建筑轮子失败

时间:2018-10-02 19:41:01

标签: python-3.x pip pycharm pytorch

我尝试安装PyTorch和TorchVision已有一段时间,以帮助我正在做的某些神经网络/ ML项目。

我的问题是,我似乎无法在PyCharm pip,Anaconda提示符或cmd / with pip3命令中正常安装。

尝试通过PyCharm运行以下命令时得到的输出:

pip install --user pytorch==0.1.2

是这个

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: started
  Running setup.py bdist_wheel for pytorch: finished with status 'error'
  Complete output from command C:\Users\Even\Anaconda3\envs\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Even\\AppData\\Local\\Temp\\pycharm-packaging\\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\Even\AppData\Local\Temp\pip-wheel-2sfgqmm7 --python-tag cp36:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Even\AppData\Local\Temp\pycharm-packaging\pytorch\setup.py", line 17, in <module>
      raise Exception(message)
  Exception: You should install pytorch from http://pytorch.org

  ----------------------------------------
  Running setup.py clean for pytorch
Failed to build pytorch
Installing collected packages: pytorch
  Running setup.py install for pytorch: started
    Running setup.py install for pytorch: finished with status 'error'
    Complete output from command C:\Users\Even\Anaconda3\envs\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Even\\AppData\\Local\\Temp\\pycharm-packaging\\pytorch\\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\Even\AppData\Local\Temp\pip-record-1jx5e1ke\install-record.txt --single-version-externally-managed --compile --user --prefix=:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Even\AppData\Local\Temp\pycharm-packaging\pytorch\setup.py", line 13, in <module>
        raise Exception(message)
    Exception: You should install pytorch from http://pytorch.org

    ----------------------------------------

  Failed building wheel for pytorch
Command "C:\Users\Even\Anaconda3\envs\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Even\\AppData\\Local\\Temp\\pycharm-packaging\\pytorch\\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\Even\AppData\Local\Temp\pip-record-1jx5e1ke\install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in C:\Users\Even\AppData\Local\Temp\pycharm-packaging\pytorch\

我也尝试过此命令(CMD):

pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m- 
win_amd64.whl

在此输出中返回的内容:

torch-0.4.1-cp36-cp36m-win_amd64.whl is not a supported wheel on this 
platform.

我可能会丢失一些重要信息,但是我一直在Google搜索,搜索论坛并询问我认识的人。没有人有答案。我希望你们中的一些人可能也遇到过同样的问题。

谢谢。

2 个答案:

答案 0 :(得分:0)

首先,验证本地终端中的安装是否完成。从https://pytorch.org/

查找Windows特定的安装

完成此操作后,请确保在pycharm中选择正确的python解释器。请参考链接:https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html,以管理特定Python解释器的软件包。

答案 1 :(得分:0)

  1. 我在https://pytorch.org/上解决了这个错误,这是错误的。并遭受

    在此不支持

    torch-0.4.1-cp36-cp36m-win_amd64.whl 平台

。也一样但是我发现是我的CUDA版本导致了该错误。我以为是8/9,但实际上是10。您可以使用pip --version检查pip和python版本。

  1. 还有一点我们应该注意。 Pip和Anaconda以不同的方式安装软件包。以前,Pytorch由Anaconda安装,但是我无法导入Anaconda Prompt(No module named torch)。我必须使用pip来安装以纠正错误。

希望这会有所帮助。