pip國內的一些鏡像python
阿里雲 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/linux
修改源方法:windows
臨時使用:
能夠在使用pip的時候在後面加上-i參數,指定pip源
pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simplescrapy
永久修改:
linux:
修改 ~/.pip/pip.conf (沒有就建立一個), 內容以下:阿里雲
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
windows:
直接在user目錄中建立一個pip目錄,如:C:\Users\xx\pip,新建文件pip.ini,內容以下url
[global] timeout = 6000 index-url = http://pypi.douban.com/simple trusted-host = pypi.douban.com
懶得本身去換的能夠直接運行如下代碼spa
特性:
1.修改下載源
2.屏蔽pip升級提示
3.延長超時等待時間code
1 import os 2 3 ini="""[global] 4 index-url = https://pypi.doubanio.com/simple/ 5 [install] 6 trusted-host=pypi.doubanio.com 7 disable-pip-version-check = true 8 timeout = 600 9 """ 10 11 pippath=os.environ["USERPROFILE"]+"\\pip\\" 12 13 if not os.path.exists(pippath): 14 os.mkdir(pippath) 15 16 with open(pippath+"pip.ini","w+") as f: 17 f.write(ini)
這下能夠愉快地使用PIP啦~blog