方法1: 国内Pypi镜像库下载
sudo -H pip install --index <源> + <包>
如:
sudo -H pip install --index https://pypi.tuna.tsinghua.edu.cn/simple scikit-learn
或:
sudo pip install -U -i https://pypi.tuna.tsinghua.edu.cn/simple scikit-learn
镜像源:
清华大学 TUNA 协会
https://pypi.tuna.tsinghua.edu.cn/simple/
pypi 镜像每 5 分钟同步一次。
中科大
https://pypi.mirrors.ustc.edu.cn/simple
与pypi同步不及时,可能无最新安装包
豆瓣
http://pypi.douban.com/simple/
安装包同步更新,但不是受信任的站点,不是https,可以手动下载安装,不方便。
方法2: 修改源方式
找到site-packages文件夹里面的index.py
修改如下:
#PyPI = Index(‘https://pypi.python.org/‘)
PyPI = Index(‘https://pypi.tuna.tsinghua.edu.cn/‘)
方法3: 临时指定源方式
pip install -U somePackage -i http://pypi.douban.com/simple/