【问题标题】:how to install pytorch in python2.7?python2.7如何安装pytorch?
【发布时间】:2021-04-07 18:21:45
【问题描述】:

我在虚拟环境中使用 python2.7。我尝试在 python2.7 中安装 pytorch,但出现以下错误:

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

  - pytorch-cpu -> python[version='3.5.*|3.6.*']
  - pytorch-cpu -> python[version='>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0']

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to.  Your current python version
is (python=2.7).  Note that conda will not change your python version to a different minor version
unless you explicitly specify that.

The following specifications were found to be incompatible with each other:



Package wheel conflicts for:
python=2.7 -> pip -> wheel
pytorch-cpu -> python[version='>=3.6,<3.7.0a0'] -> pip -> wheel
Package vc conflicts for:
python=2.7 -> sqlite[version='>=3.27.2,<4.0a0'] -> vc[version='14.*|>=14,<15.0a0|>=14.1,<15.0a0']
python=2.7 -> vc[version='9.*|>=9,<10.0a0']
pytorch-cpu -> numpy[version='>=1.11'] -> vc[version='14|14.*|>=14,<15.0a0']
pytorch-cpu -> vc[version='>=14.1,<15.0a0']
Package cffi conflicts for:
pytorch-cpu -> cffi
pytorch-cpu -> python[version='>=3.6,<3.7.0a0'] -> pip -> requests -> urllib3[version='>=1.21.1,<1.25'] -> cryptography[version='>=1.3.4'] -> cffi[version='>=1.7']
python=2.7 -> pip -> requests -> urllib3[version='>=1.21.1,<1.25'] -> cryptography[version='>=1.3.4'] -> cffi[version='>=1.7']
Package pip conflicts for:
python=2.7 -> pip
pytorch-cpu -> python[version='>=3.6,<3.7.0a0'] -> pip
Package setuptools conflicts for:
python=2.7 -> pip -> setuptools
pytorch-cpu -> python[version='>=3.6,<3.7.0a0'] -> pip -> setuptools
Package msgpack-python conflicts for:
python=2.7 -> pip -> cachecontrol -> msgpack-python
pytorch-cpu -> python[version='>=3.6,<3.7.0a0'] -> pip -> cachecontrol -> msgpack-python

我尝试了 conda install pytorch-cpu -c pytorch 和链接(https://pytorch.org/get-started/locally/)。但它不起作用。那么我应该怎么做才能在python version2.7中安装torch?我想安装 pytorch cpu 版本。

请帮忙:)

【问题讨论】:

  • 对于 pytorch 和通常的机器学习,最好在虚拟环境中安装 python 3

标签: python python-2.7 pytorch torch


【解决方案1】:

这是PyTorch official download page的链接

从这里,您可以根据您的环境和操作系统选择python版本(2.7)和CUDA(无)等相关细节。

其他有用的链接:

【讨论】:

    【解决方案2】:

    似乎 pytorch 尝试安装一些需要 python >= 3.6 版本的包。

    Package wheel conflicts for:
    python=2.7 -> pip -> wheel
    pytorch-cpu -> python[version='>=3.6,<3.7.0a0'] -> pip -> wheel
    

    您必须在命令中指定要安装 pytorch 的 python 版本

    【讨论】:

    • 那么,你的意思是我应该为python2.7指定pytorch版本?
    • 你用的是什么操作系统?请注意,PyTorch 不支持 Windows 上的 Python 2.7。
    • 我使用 Windows。我的天啊!我不能在 Windows 上的 python2.7 中使用 torch 吗?:(
    【解决方案3】:

    对我来说链接https://www.learnopencv.com/installing-deep-learning-frameworks-on-ubuntu-with-cuda-support/中的方法 工作。

    这就是我的做法:

    !pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl

    【讨论】:

      【解决方案4】:

      先用python2.7安装conda:
      conda install pytorch torchvision torchaudio cpuonly -c pytorch

      然后激活环境:
      conda 激活 python2

      然后安装pytorch:
      conda install pytorch torchvision torchaudio cpuonly -c pytorch

      检查确认:

      python    
      import torch
      print(torch._ _version_ _)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-26
        • 2015-03-26
        • 2012-04-26
        • 2022-07-13
        • 2016-04-24
        • 2016-09-14
        相关资源
        最近更新 更多