pip 源 修改
阿新 • • 發佈:2019-01-04
國內主流的pypi源:
- 豆瓣
- 阿里雲
- 清華
- 中科大
- (官方 )
[global]
index-url = https://pypi.doubanio.com/simple
extra-index-url = https://mirrors.aliyun.com/pypi/simple/
https://pypi.tuna.tsinghua.edu.cn/simple/
https://mirrors.ustc.edu.cn/pypi/web/simple/
https://pypi.org/simple/
[install]
trusted-host = pypi.doubanio .com
mirrors.aliyun.com
pypi.tuna.tsinghua.edu.cn
mirrors.ustc.edu.cn
pypi.org
disable-pip-version-check = true
timeout = 6000
注: 不要重複寫成
extra-index-url=...
extra-index-url=...
trusted-host = ...
trusted-host = ...
會報錯(DuplicationError
虛擬環境中的 pip.conf 配置
對新建的專案,往往會在其root目錄建立虛擬環境,此時pip如果想更改配置,需在
Inside a virtualenv:
On Unix and macOS the file is $VIRTUAL_ENV/pip.conf
On Windows the file is: %VIRTUAL_ENV%\pip.ini
比如用pipenv建立虛擬環境,如果想改某專案下的 pip 配置,則首先在對應的專案目錄下啟動虛擬環境pipenv shell
, 然後用 which pip
檢視路徑,如:
/home/XX/.local /share/virtualenvs/project-6CoWjSse/bin/pip
然後在對應的 /project-6CoWjSse/
下建立 一個 pip.conf
,然後根據需求更改配置即可。
pipenv 的 源修改
default
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"改為豆瓣源
[[source]]
url = "https://pypi.doubanio.com/simple/"
verify_ssl = true
name = "pypi.doubanio.com"