pip更换源,换成国内镜像
由于使用pip或pip3安装python第三方包时,经常出现read timed out问题,所以需要将pip的官方软件源服务器换成国内的镜像服务器,从而提升python软件包安装效率和成功率。
1、pip国内镜像地址
阿里云 http://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/
2、pip换源方法
2.1 pip永久换源
pip永久换源:(个人推荐阿里云的源)
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
在cmd命令行中输入上述命令即可。下图为例
最后,升级 pip 到最新的版本
python3.8.5请用方式一升级:
python -m pip install --user --upgrade pip
python其余版本可以用方式二:
pip install pip -U
如果方式二方法升级失败,出现错误:Script file ‘D:\software_install\Anaconda_install\Scripts\pip-script.py’ is not present.参考这个博客解决错误:Script file ‘D:\software_install\Anaconda_install\Scripts\pip-script.py‘ is not present.完美解决方法,然后再尝试用方式一解决。
方式一的参考博客是错误Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: ‘c:\programdata\anaconda3\lib\site-packages\pip-18.1.dist-info\entry_points.txt’ Consider using the --user
option or check the permissions.的解决方法
2.2 临时指定pip源
# 以使用清华大学的镜像源安装matplotlib为例
pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple/
参考博客
浅析Python3 pip换源问题