天使漫步IT工作室天使漫步IT工作室

设置国内pip源,加速pip更新速度


Warning: count(): Parameter must be an array or an object that implements Countable in /www/wwwroot/u11u.com/usr/themes/wq/functions.php on line 110

Warning: count(): Parameter must be an array or an object that implements Countable in /www/wwwroot/u11u.com/usr/themes/wq/functions.php on line 116

前言

pip的默认镜像在国外,其速度可想而知,解决这个问题的办法只有一个,使用国内的大厂镜像来进行加速(常识)。

<br/>

一、 -i 加 url 方式(一次有效)

例如使用豆瓣的镜像,命令行如下:

# pip install web.py -i http://pypi.douban.com/simple

如果安装过程中报错,则可以添加--trusted-host 参数,其完整命令行如下:

# pip install web.py -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

以上办法只能对一次命令有效。

<br/>

二、配置全局默认镜像

需要创建或修改配置文件(一般都是创建)

  • linux方法(复制命令执行即可,阿里云镜像):
1. mkdir ~/.pip
2. cat > ~/.pip/pip.conf << EOF
3. [global]
   trusted-host=mirrors.aliyun.com
   index-url=http://mirrors.aliyun.com/pypi/simple/
   EOF
  • windows设置方法:
1. 在%HOMEPATH%\pip\pip.ini)
2. 复制粘贴一下代码(豆瓣镜像):
   [global]
   index-url = http://pypi.douban.com/simple
   [install]
   trusted-host=pypi.douban.com

保存后即可生效,这样在使用pip来安装时,会默认调用该镜像。
<br/>

三、国内常用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/

根据自己的喜好修改下以上代码即可使用。

本站原创,欢迎转载,转载敬请标明出处:天使漫步IT工作室 » 设置国内pip源,加速pip更新速度
添加新评论


Warning: Use of undefined constant php - assumed 'php' (this will throw an Error in a future version of PHP) in /www/wwwroot/u11u.com/usr/themes/wq/comments.php on line 38