Python pip修改镜像源为豆瓣源 常常遇到pip装包时速度过慢或者无法安装(请求超时)等问题,这个时候你就需要考虑一下给pip换源了

一、临时的方法

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

其他源:

阿里云 https://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) http://pypi.douban.com/simple/ 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

这两个示例方法一般

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

二、永久的方法

这里不推荐使用永久的方法,不做详解

本地安装

方式一:.whl包

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

方式二:.tar.bz2

将已经下好的包移动到 …\Anaconda3\pkgs目录下,在该目录下打开CMD,运行如:

conda install --use-local **.tar.bz2

参考文章

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: