How to configure PIP per config file to use a proxy (with authentification)?

后端 未结 4 1799
灰色年华
灰色年华 2021-02-01 08:29

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

相关标签:
4条回答
  • 2021-02-01 09:12

    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
    
    0 讨论(0)
  • 2021-02-01 09:21

    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

    0 讨论(0)
  • 2021-02-01 09:28

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

    pip install --proxy userid:password@proxy.domain.com:yourport
    
    0 讨论(0)
  • 2021-02-01 09:28

    If package that you are trying to install has dependencies it's best to create pip.ini for system wide configuration, in windows you can do this in powershell:

    mkdir c:\programdata\pip\
    new-item c:\programdata\pip\pip.ini
    

    and add this to your pip.ini

    [global]
    proxy = http://domain\user:pwd@proxy_hostname_or_ip:port 
    

    and then everything should work fine, as HTTP_PROXY variable didn't work for me.

    Make sure to save file as ansi or windows1252 in VSCode as UTF files are not read properly.

    0 讨论(0)
提交回复
热议问题