CondaHTTPError with conda install command

First of all, we must understand why this problem occurs. My personal understanding is: conda install mainly downloads various packages from the Internet to your own environment, but due to various technical reasons, most of the packages under the advanced framework are abroad. However, due to the national conditions of our country, it is easy to connect to a timeout when accessing external networks to download things, causing download failure

There are many mirror images in China, such as Tsinghua Mirror. I think Tsinghua has downloaded many packages from the Internet and put them on its own mirror website. Then when we download, specify the download site Tsinghua mirror site, then conda will find the package to download from this site, so as to avoid connecting to the external network

For example, use Douban source (also a mirror website, various packages of python) to download numpy

pip install -i https://pypi.douban.com/simple/ numpy

This is a pip command download, you can specify the mirror website to be used through -i. But there is no -i when changing to conda

So how can conda use mirror sites? When Anaconda is installed, there will be a .condarc file in the user folder of the system disk. Search can be found. Open with Notepad

The first three are mirror sites of Tsinghua University. I understand default as the server site where the package itself is actually located.

After the mirror website is added, I think it is to find the package to download according to this channel order. The function of show_channel is to display the download site when the package is found

This mirror website can open the notebook and paste it in. This is the first method.

The second method is to use the cmd command, which can be executed in any environment, whether it is a local environment or a virtual environment. This is my guess. After all, there is only one .condrac file. The following code works as a copy and paste

C:\Users\User>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

C:\Users\User>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

C:\Users\User>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

C:\Users\User>conda config --set show_channel_urls yes

Note that these three images must be written, otherwise an error will be reported, and I don’t know what to ask 

After configuring the file, you don’t have to think about mirroring anymore when you execute commands such as conda install numpy

Guess you like

Origin blog.csdn.net/qq_40923413/article/details/108082382