pip install镜像源(更新和换源)
pip install镜像源(更新和换源)以及指定安装来源安装包分享by itlife365.com
1.pip安装依赖包默认访问的源:
因为服务器架设在国外的缘故,很多时候不好用网速不行,这时候就需要选择国内的一些安装源安装相应的包
https://pypi.Python.org/simple/
2.设置默认源
打开cmd命令行,升级 pip 到最新的版本 (>=10.0.0) 后进行配置:
#更新pip源
python -m pip install --upgrade pip
#换源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
如果您的 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip:
python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
3、其他的镜像源网址:
豆瓣 ?http://pypi.douban.com/?
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/?
清华: https://pypi.tuna.tsinghua.edu.cn/simple
阿里云: http://mirrors.aliyun.com/pypi/simple/
华中理工大学: http://pypi.hustunique.com/
山东理工大学: http://pypi.sdutlinux.org/?
————————————————
-i https://pypi.tuna.tsinghua.edu.cn/simple
pip 更新指定来源网站
要使用pip更新指定源站点的包,你可以使用-i或--index-url参数来指定源。例如,如果你想从PyPI的中国镜像站点更新包,可以使用以下命令:
pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
这里的some-package是你想要更新的包名。-i参数后面跟的URL是指定的源站点。
如果你想要永久更改默认源,可以创建或修改pip.conf(Unix系统位于~/.pip/pip.conf,Windows系统位于%HOME%\pip\pip.ini),
例如:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
这样配置后,以后使用pip安装或更新包时将默认使用这个源。
how-to-change-pip-install-source-python
--end
