安静的沸腾 2024-06-02 21:05 采纳率: 60%
浏览 66

现在创建一个虚拟环境后,想要在这个虚拟环境安装torch,无论是pip还是conda都不行,请问一下这个我需要怎么解决呀。

现在创建一个虚拟环境后,想要在这个虚拟环境安装torch,无论是pip还是conda都不行,请问一下这个我需要怎么解决呀,谢谢大家。

conda安装错误显示是
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  • torchvision
  • pytorch
  • torchaudio

Current channels:

To search for alternate channels that may provide the conda package you're
looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

pip安装错误显示的是
Looking in indexes: https://download.pytorch.org/whl/cu118
ERROR: Could not find a version that satisfies the requirement torch==2.0.0+cu118 (from versions: none)
ERROR: No matching distribution found for torch==2.0.0+cu118

  • 写回答

3条回答 默认 最新

  • 檀越@新空间 2024-06-02 21:05
    关注

    晚上好🌙🌙🌙
    本答案参考ChatGPT-3.5

    根据你提供的信息,问题出现在无法在虚拟环境中安装torch。这可能是由于没有可用的渠道或匹配的发行版导致的。下面是解决此问题的几种可能方法:

    1. 使用官方渠道:首先尝试使用torch的官方渠道进行安装。可以使用以下命令尝试使用pip安装:

      pip install torch
      

      如果使用pip安装不起作用,可以尝试使用以下命令使用conda安装:

      conda install torch
      

      如果你想要安装特定版本的torch,可以在上述命令后面加上要安装的版本号。

    2. 更换镜像源:如果官方渠道无法使用或速度较慢,可以尝试更换conda镜像源。可以使用以下命令更换为清华大学的镜像源:

      conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
      conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
      conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
      conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
      

      更换镜像源后,再次尝试使用conda安装torch。

    3. 使用另外一个版本:如果你尝试安装的torch版本不可用,你可以尝试安装其他版本。可以在torch官方网站上查找可用的版本并尝试安装。例如,下面的命令将尝试安装torch-1.9.0版本:

      pip install torch==1.9.0
      

    通过以上几种方法之一,你应该能够在虚拟环境中成功安装torch。希望这些建议对你有帮助!

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 6月2日