How to use pip on windows behind an authenticating proxy

前端 未结 9 1239
谎友^
谎友^ 2020-11-28 19:23

My computer is running windows behind a proxy on a windows server (using active directory), and I can\'t figure out how to get through it with pip (in python3).

相关标签:
9条回答
  • 2020-11-28 19:55

    I have tried 2 options which both work on my company's NTLM authenticated proxy. Option 1 is to use --proxy http://user:pass@proxyAddress:proxyPort

    If you are still having trouble I would suggest installing a proxy authentication service (I use CNTLM) and pointing pip at it ie something like --proxy http://localhost:3128

    0 讨论(0)
  • 2020-11-28 19:59

    same issue on windows10 and above solutions are not working for me.

    use a emulator console tool like cygwin and then do it the default linux way:

    export http_proxy=<proxy>
    export https_proxy=<proxy>
    pip install <package>
    

    and things are working fine.

    0 讨论(0)
  • 2020-11-28 20:01

    I had the same issue on a remote windows environment. I tried many solutions found here or on other similars posts but nothing worked. Finally, the solution was quite simple. I had to set NO_PROXY with cmd :

    set NO_PROXY="<domain>\<username>:<password>@<host>:<port>"
    pip install <packagename>
    

    You have to use double quotes and set NO_PROXY to upper case. You can also add NO_PROXY as an environment variable instead of setting it each time you use the console.

    I hope this will help if any other solution posted here works.

    0 讨论(0)
  • 2020-11-28 20:10

    I had a similar issue, and found that my company uses NTLM proxy authentication. If you see this error in your pip.log, this is probably the issue:

    Could not fetch URL http://pypi.python.org/simple/pyreadline: HTTP Error 407: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )

    NTLMaps can be used to interface with the NTLM proxy server by becoming an intermediate proxy.

    Download NTLMAPs, update the included server.cfg, run the main.py file, then point pip's proxy setting to 127.0.0.1:.

    I also needed to change these default values in the server.cfg file to:

    LM_PART:1
    NT_PART:1
    
    # Highly experimental option. See research.txt for details.
    # LM - 06820000
    # NT - 05820000
    # LM + NT - 
    NTLM_FLAGS: 07820000
    

    http://ntlmaps.sourceforge.net/

    0 讨论(0)
  • 2020-11-28 20:11

    install cntlm: Cntlm: Fast NTLM Authentication Proxy in C

    Config cntlm.ini:

    Username ob66759

    Domain NAM

    Password secret

    Proxy proxy1.net:8080

    Proxy proxy2.net:8080

    NoProxy localhost, 127.0.0.*, 10.*, 192.168.*

    Listen 3128

    Allow 127.0.0.1

    #your IP

    Allow 10.106.18.138

    start it:

    cntlm -v -c cntlm.ini

    Now in cmd.exe:

    pip install --upgrade pip --proxy 127.0.0.1:3128

    Collecting pip
      Downloading https://files.pythonhosted.
    44c8a6e917c1820365cbebcb6a8974d1cd045ab4/
    
        100% |███████████████████████████████
    Installing collected packages: pip
      Found existing installation: pip 9.0.1
        Uninstalling pip-9.0.1:
          Successfully uninstalled pip-9.0.1
    
    Successfully installed pip-10.0.1
    

    works!

    You can also hide password: https://stormpoopersmith.com/2012/03/20/using-applications-behind-a-corporate-proxy/

    0 讨论(0)
  • 2020-11-28 20:13

    You may also run into problems with certificates from your proxy. There are plenty of answers here on how to retrieve your proxy's certificate.

    On a Windows host, to allow pip to clear your proxy, you may want to set an environment variable such as:

    PIP_CERT=C:\path\to\certificate\file\in\pem\form\myproxycert.pem
    

    You can also use the --cert argument to PIP with the same result.

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