关于git:gitpipeasyinstall代理设置大全

4次阅读

共计 1252 个字符,预计需要花费 4 分钟才能阅读完成。

在公司内网环境中,拜访公网往往须要通过公司的代理,对于浏览器、IDE 等开发工具,都提供了设置代理的配置,对于 git、pip、easy_install 等 CLI 工具,则须要通过命令或配置文件进行代理设置,在此做个笔记,防止每次用到了都去 Google。

公司内网的代理,拜访时往往须要用户名明码,在 URL 中带用户名明码的格局如下:

http://user:password@proxy_host:port

git 代理配置

设置代理

git config --global http.proxy http://user:password@proxy_host:port
git config --global https.proxy http://user:password@proxy_host:port

给指定域名设置代理
如给 github.com 设置代理

git config --global http.https://github.com.proxy http://user:password@proxy_host:port

勾销代理

git config --global --unset http.proxy
git config --global --unset https.proxy
git config --global --unset http.https://github.com.proxy

pip 设置代理

  • 间接在命令行中减少 –proxy 参数来指定代理
pip install numpy --proxy http://user:password@proxy_host:port
  • 通过 pip config set 命令设置代理
pip config set global.proxy http://user:password@proxy_host:port

这里要留神下,pip 官网帮忙文档说的设置办法为 pip config [<file-option>] set name value,这里的 name 间接写 proxy 会报 ValueError: not enough values to unpack (expected 2, got 1) 谬误,name 要写为 <profile>.<key> 格局,如这里的 global.proxy
此操作和间接改配置文件成果雷同,但在不确定配置文件地位的时候,能够应用此操作。

  • 间接批改 pip.ini 文件进行配置
[global]
proxy=http://user:password@proxy_host:port 

easy_install 代理设置

Windows 中

set http_proxy=http://user:password@proxy_host:port
set https_proxy=http://user:password@proxy_host:port

Linux 中

export http_proxy=http://user:password@proxy_host:port
export https_proxy=http://user:password@proxy_host:port
正文完
 0