pip下載安裝Python庫很慢,可使用國內(nèi)鏡像網(wǎng)站加速煤墙,操作方法有二梅惯。
命令行使用參數(shù)項(xiàng)-i
[root@localhost ~]# pip install -i https://pypi.douban.com/simple/ sqlalchemy
pip添加配置文件
上面方法每次安裝Python庫時都要輸入鏡像網(wǎng)址,很麻煩仿野∠臣酰可以給pip添加配置文件,以后使用pip安裝Python鏡像庫就不用帶 "-i" 參數(shù)項(xiàng)脚作。
查看用戶主目錄下有沒有"~/.pip/pip.conf"文件葫哗,沒有則創(chuàng)建。
[root@localhost ~]# mkdir .pip
[root@localhost ~]# touch .pip/pip.conf
打開文件球涛,添加以下配置項(xiàng)
[global]
index-url=http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
可選鏡像網(wǎng)址
豆瓣
[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
清華大學(xué)
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn