各位在使用pip下载第三方库的时候肯定有一个困惑,那就是:
外国网实在是太慢了!!!
那有没有什么办法可以提速呢?
用中国网下载第三方库不就好了。
https://pypi.tuna.tsinghua.edu.cn/simple
这是清华大学的国内镜像,包含了Python的大部分第三方库。
安装时,输入:
pip install package -i https://pypi.tuna.tsinghua.edu.cn/simple
package是你要安装的包的名字。
比如我要安装pygame库,输入:
pip install pygame -i https://pypi.tuna.tsinghua.edu.cn/simple
你也可以到https://pypi.tuna.tsinghua.edu.cn/simple下载第三方库的.whl文件,用pip安装(这里以dlib的whl文件举例):
pip install dlib-19.8.1-cp36-cp36m-win_amd64.whl
这种方法不推荐,你需要到网站里翻好久才能找到对应的库
永久修改
window下,在用户目录里新建一个pip文件夹如c:\users\xxx\pip\,新建一个pip.ini文件,在里面输入如下内容即可:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
下次下载时,只需输入
pip install package