pip加速

pip下载安装Python库很慢,可使用国内镜像网站加速,操作方法有二。

命令行使用参数项-i

[root@localhost ~]# pip install -i https://pypi.douban.com/simple/ sqlalchemy

pip添加配置文件

上面方法每次安装Python库时都要输入镜像网址,很麻烦。可以给pip添加配置文件,以后使用pip安装Python镜像库就不用带 "-i" 参数项。

查看用户主目录下有没有"~/.pip/pip.conf"文件,没有则创建。

[root@localhost ~]# mkdir .pip
[root@localhost ~]# touch .pip/pip.conf

打开文件,添加以下配置项

[global] 
index-url=http://pypi.douban.com/simple
[install] 
trusted-host=pypi.douban.com

可选镜像网址

豆瓣

[global] 
index-url=http://pypi.douban.com/simple 
[install] 
trusted-host=pypi.douban.com

阿里云

[global] 
index-url=http://mirrors.aliyun.com/pypi/simple 
[install] 
trusted-host=mirrors.aliyun.com

清华大学

[global] 
index-url=https://pypi.tuna.tsinghua.edu.cn/simple 
[install] 
trusted-host=pypi.tuna.tsinghua.edu.cn
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。