【anaconda】Collecting package metadata (current_repodata.json): failed / Solving environment: failed

文章目录

    • 一、问题
    • 二、解决步骤
      • (1)步骤一
      • (2)步骤二
      • (3)步骤三
      • (4)步骤四
      • (5)另外的解决办法一:pip安装
      • (6)另外的解决办法二
      • (7)另外的解决办法三:更改镜像源
    • 三、参考

一、问题

  • win10下,安装完conda之后打算安装pytoch时报错,解决步骤里面讲了我的多种尝试,应该可以解决此类大部分问题。

二、解决步骤

(1)步骤一

刚安装完conda之后打算安装pytoch时:

  • 命令行:
PS C:\Users\25387> conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
  • 报错
Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/pytorch/win-64/current_repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
'https://conda.anaconda.org/pytorch/win-64'

(2)步骤二

参考Collecting package metadata (current_repodata.json): failed之后按以下操作将文件粘贴过去:

当在windows下面的Anaconda的命令行中运行 conda时,如果出现Collecting package metadata (current_repodata.json): failed
的错误提示,可以按照下面的方式来解决掉:把路径“Anaconda3/Library/bin ”下面的文件复制到路径“Anaconda3/DLLs”下:
libcrypto-1_1-x64.dll
libssl-1_1-x64.dll
  • 再次运行命令行:
PS C:\Users\25387> conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
  • 报错
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:

  - cudatoolkit=10.2

Current channels:

  - https://conda.anaconda.org/pytorch/win-64
  - https://conda.anaconda.org/pytorch/noarch
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/win-64
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/noarch
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch

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.

(3)步骤三

根据博客conda安装环境报错:Solving environment: failed with initial frozen solve.的步骤:

  • 查一下conda版本:conda -V
  • 更新conda到最新版本:conda update -n base conda
  • 查一下conda版本:conda -V
  • 第二次更新conda到最新版本:conda update -n base conda
  • 多等一会儿
  • 然后执行:conda update --all
  • 再运行之前的程序,如果可以,问题解决。

(4)步骤四

  • 如果还没有解决,进行以下步骤:
  • 有可能是在安装anaconda时错误,建议重装一遍anaconda,勾选自动添加环境就变量的选项。
  • 运行命令行,报以下错误,也有可能是在安装cuda和cudnn时,出现的错误,我在安装cudnn时,直接将配置文件复制到了cuda中,覆盖了其中的两个文件,后来重新安装了cuda,问题的到了解决。
PS C:\Users\25387> conda install pytorch torchvision cudatoolkit=10.2 -c pytorch

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:

  - cudatoolkit=10.2

Current channels:

  - https://conda.anaconda.org/pytorch/win-64
  - https://conda.anaconda.org/pytorch/noarch
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/win-64
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/noarch
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch

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.
  • 对cuda进行环境变量设置参考博客:Win10上安装CUDA和CUDNN
  • 环境变量配置好如下:
    【anaconda】Collecting package metadata (current_repodata.json): failed / Solving environment: failed_第1张图片

(5)另外的解决办法一:pip安装

  • 不得已的办法:使用pip安装
pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html

(6)另外的解决办法二

  • 解决方法链接: Anaconda使用conda连接网络出现错误

  • 链接:解决办法

  • 将用户目录下的:.condarc改为如下所示,改为如下:

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
  
proxy_servers: 
    http: socks5://127.0.0.1:1080

ssl_verify: False
show_channel_urls: True
allow_other_channels: True

(7)另外的解决办法三:更改镜像源

  • 问题:
An HTTP error occurred when trying to retrieve this URL.
  • 解决办法:
  • 如果给 Anaconda 配置了环境变量,可以直接在 cmd 窗口中执行;如果没有配置环境变量,则在 Anaconda Prompt 中执行,如果没有配置环境变量,在Anaconda Prompt 中执行如下命令,为 Anaconda 配置清华大学镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
  • 或者将用户目录下的:.condarc改为如下所示,更改镜像源
channels:
  - conda-forge
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true

三、参考

  • Collecting package metadata (current_repodata.json): failed
  • conda安装环境报错:Solving environment: failed with initial frozen solve.
  • Anaconda使用conda连接网络出现错误
  • Anaconda 报错Multiple Errors Encountered 或 Anaconda An HTTP error occurred when trying to retrieve th
  • Win10上安装CUDA和CUDNN - 最新版的cuda和cudnn安装教程,优先。

你可能感兴趣的:(python,anaconda,win10,pytorch)