python 如何新增國內源 PyPI使用國內源

2021-10-11 11:45:23 字數 1548 閱讀 9906

# pip install web.py -i

如果有如下報錯:

請使用命令:

# pip install web.py -i --trusted-host pypi.douban.com

如果想配置成預設的源,方法如下:

需要建立或修改配置檔案(一般都是建立),

linux的檔案在~/.pip/pip.conf,

windows在%homepath%\pip\pip.ini),

修改內容為:

[global]

index-url =

[install]

trusted-host=pypi.douban.com

這樣在使用pip來安裝時,會預設呼叫該映象。

臨時使用其他源安裝軟體包的python指令碼如下:

#!/usr/bin/python

import os

package = raw_input("please input the package which you want to install!\n")

command = "pip install %s -i --trusted-host pypi.mirrors.ustc.edu.cn" % package

os.system(command)

也可以使用讀入檔案進行安裝。

ok,僅以記錄一下,以便於後期查閱!

------日期:2023年11月1日 增加python配置pip預設源指令碼,複製到pip_source.py,執行即可。

#!/usr/bin/python#coding: utf-8

importplatformimportos

os_type=platform.system()if "linux" ==os_type:

filedirpath= "%s/.pip" % os.path.expanduser('~')

filepath= "%s/pip.conf" %filedirpathif notos.path.isdir(filedirpath):

os.mkdir(filedirpath)

fo= open(filepath, "w")

fo.write("[global]\nindex-url=")

fo.close()print "configuration is complete"

elif "windows" ==os_type:

filedirpath= "%s\\pip" % os.path.expanduser('~')

filepath= "%s\\pip.ini" %filedirpathif notos.path.isdir(filedirpath):

os.mkdir(filedirpath)

fo= open(filepath, "w")

fo.write("[global]\nindex-url=")

fo.close()print "configuration is complete"

else:

exit("your platform is unknow!")

Manjaro 新增國內源和安裝搜狗輸入法

manjaro 系統雖然比 ubuntu 用著穩定,但有些小地方沒有 ubuntu 人性化,比如預設安裝完的系統貌似沒有中國的,ubuntu 估計是用的人多,所以安裝完後會根據所在地給你配置更新的源。下面是網上抄來的新增中科大源的方法 先排列源 sudo pacman mirrors g 同步並優化...

加速 為conda新增國內映象

有沒有覺得用conda安裝包時超級慢呢?而且經常卡住,動都動不了的那種。超級尷尬了,很多時候都逼得我想za電腦 我是個衝動的猿類 不管了,該死的default映象用不下去了崩潰了 換!貼 有操作教程!幹!conda config add channels conda config set show ...

ubuntu下docker新增國內映象

伺服器環境ubuntu16.04 第一步 更換映象位址 在伺服器本機的 etc docker 下新建daemon.json,並輸入以下內容 如果需要更換不同的映象位址,直接替換掉 即可 root nulige vi etc docker daemon.json 第二步 劃重點 很多資料都沒有這一步,...