How to configure PIP per config file to use a prox

2019-04-01 11:30发布

I used to set up environment evariables http_proxy and https_proxy (with user + password) in the past to use Pip (on Windows) behind a corporate proxy. But recently I needed to tell Pip to use a proxy without setting up environment variables as this conflicted with git configuration in combination with SSL Certificates which I get to work only by removing environment variables for proxy.

Fortunately you can configure PIP with an pip.ini file as described here: https://pip.pypa.io/en/stable/user_guide/#config-file

The detailed answer to my own question follows below.

3条回答
太酷不给撩
2楼-- · 2019-04-01 12:18

Here are the steps how to configure proxy (with auth.) in pip's config file (pip.ini)

  1. (if it does not already exist) Create a folder named 'pip' and inside it a file named 'pip.ini' as described here: https://pip.pypa.io/en/stable/user_guide/#config-file (location an name may differ per platform - e.g. on Windows it's %APPDATA%\pip\pip.ini)
  2. edit pip.ini file and add

    [global]
    proxy = http://user:password@proxy_name:port
    
  3. That's it!

Example for proxy with authentification (user + password):

proxy = http://butch:secret@proxyname:1234

proxyname can be an IP adress, too

Example for proxy without auth.:

proxy = http://proxyname:1234

查看更多
smile是对你的礼貌
3楼-- · 2019-04-01 12:21

In order to add a proxy option in the terminal the following line solved the problem for me:

pip install package_name_here --proxy https://user_name:password@proxyname:port
查看更多
何必那么认真
4楼-- · 2019-04-01 12:34

You need to set proxy option while installing the package. example:

pip install --proxy userid:password@proxy.domain.com:yourport
查看更多
登录 后发表回答