pytorch安装错误

纠正

安装pytorch

首先要创建虚拟环境:conda activate pytorch

从(base)->(pytorch)

 

结果出现错误

Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url

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.

SSLError(MaxRetryError('HTTPSConnectionPool(host=\'mirrors.tuna.tsinghua.edu.cn\', port=443): Max retries exceeded with url: /anaconda/cloud/conda-forge/noarch/repodata.json (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'ssl3_get_server_certificate\', \'certificate verify failed\')])")))'))

因为正常安装pytorch是后面要加-c pytorch 的,但是我这里本来是想用清华源的

这里输入

conda config --set show_channel_urls yes让conda告诉我们下载的时候用的哪个镜像源

之后输入conda install pytorch torchvision torchaudio cudatoolkit=11.3  -c pytorch开始安装,结果出现以错误

pytorch安装错误_第1张图片

 

原因可能是:清华源有误,找到C:\Users\Administrator文件下的.condarc文件将里面的内容改为:

channels:
  - defaults
show_channel_urls: true
default_channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: http://mirr

输入:conda config --add channels conda-forge

之后再在Anaconda prompt中输入conda install pytorch torchvision torchaudio cudatoolkit=11.3  -c pytorch  就安装成功了,

判断是否安装成功

输入pip list  出现

pytorch安装错误_第2张图片

 

或者输入python,之后输入import torch 不报错即表示安装成功

你可能感兴趣的:(Python学习,python,pytorch,深度学习)