Two methods for Python pip to modify the mirror source to Douban source

Python pip changes the mirror source to Douban source.
It is often encountered that the pip package is too slow or cannot be installed (request timeout). At this time, you need to consider changing the pip source.

1. Temporary method

pip

-i https://pypi.doubanio.com/simple
-i https://pypi.douban.com/simple

pip install -r requirements.txt or "package name"-i https://pypi.douban.com/simple
pip install -r requirements.txt or "package name"-i https://pypi.doubanio.com/simple

pip install -r requirements.txt -i https://pypi.doubanio.com/simple
pip install pygame -i https://pypi.doubanio.com/simple

pip install -r requirements.txt -i https://pypi.douban.com/simple
pip install pygame -i https://pypi.douban.com/simple

Other sources:

Alibaba Cloud https://mirrors.aliyun.com/pypi/simple/
University of Science and Technology of China https://pypi.mirrors.ustc.edu.cn/simple/
Douban http://pypi.douban.com/simple /
Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/
University of Science and Technology of China http://pypi.mirrors.ustc.edu.cn/simple/

These two example methods generally

conda

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/conda-forge 
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/pytorch/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/

conda config --set show_channel_urls yes

conda config --remove-key channels

2. The permanent method

The permanent method is not recommended here, and no detailed explanation is given

local installation

Method 1: .whl package

pip install  **.whl		(写全该文件的路径)

Method 2: .tar.bz2

  • Move the downloaded package to the ...\Anaconda3\pkgs directory,
  • Open CMD in this directory, run as:
conda install --use-local  **.tar.bz2

Guess you like

Origin blog.csdn.net/weixin_43476776/article/details/125334704
Recommended