國(guó)內(nèi)安裝很多大的包都會(huì)發(fā)現(xiàn)速度非常慢,這是因?yàn)閜ip默認(rèn)的安裝源一般都是在國(guó)外的,通常只有幾十K的速度,所以安裝個(gè)小包時(shí)沒有感覺,但安裝大包時(shí)就很明顯了。
1、如果你只是想臨時(shí)性的換一個(gè)安裝源,那么用-i選項(xiàng)臨時(shí)指定本次安裝的安裝源則可:
pip install labelme -i https://pypi.tuna.tsinghua.edu.cn/simple文章來源:http://www.zghlxwxcb.cn/news/detail-416032.html
2、如果你想永久性的添加國(guó)內(nèi)鏡像安裝源
2.1、用pip -v config list命令可以看到site變量在/usr/pip.conf文件中
sudo pip -v config list
For variant 'global', will try loading '/etc/xdg/pip/pip.conf'
For variant 'global', will try loading '/etc/pip.conf'
For variant 'user', will try loading '/root/.pip/pip.conf'
For variant 'user', will try loading '/root/.config/pip/pip.conf'
For variant 'site', will try loading '/usr/pip.conf'
2.2、添加以下內(nèi)容到上一章節(jié)里’site’指定的文件/usr/pip.conf中
pip首先從index-url指定的源中去安裝,在index-url指定的源中找不到安裝包的話,會(huì)從extra-index-url指定的源中去安裝。加上trusted-host和ssl_verfy: false可以減少很多安裝源安全驗(yàn)證性的問題,會(huì)帶來很多便利性,當(dāng)然也可能會(huì)帶來安全的風(fēng)險(xiǎn)。文章來源地址http://www.zghlxwxcb.cn/news/detail-416032.html
[global]
index-url = https://pypi.mirrors.ustc.edu.cn/simple/
extra-index-url = https://pypi.tuna.tsinghua.edu.cn/simple
https://mirrors.aliyun.com/pypi/simple
hppts://pypi.douban.com/simple
[install]
trusted-host=
pypi.tuna.tsinghua.edu.cn
mirrors.aliyun.com
pypi.douban.com
pypi.mirrors.ustc.edu.cn
ssl_verify: false
3、下面是一些推薦的速度快,安裝包新的國(guó)內(nèi)鏡像源:
名字 | URL |
---|---|
中國(guó)科技大學(xué) | https://pypi.mirrors.ustc.edu.cn/simple/ |
清華大學(xué) | https://pypi.tuna.tsinghua.edu.cn/simple/ |
阿里云 | https://mirrors.aliyun.com/pypi/simple/ |
豆瓣 | https://pypi.douban.com/simple/ |
到了這里,關(guān)于為pip永久性添加國(guó)內(nèi)鏡像安裝源的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!