Closed sagar-m closed 7 years ago
Using package managers while behind a PAC network still seems to be an unsolved problem, so I don't think I can help you there.
The 407 response means Proxy Authentication Required. Hopefully, your proxy just needs Basic authentication. See http://pypac.readthedocs.io/en/latest/user_guide.html#proxy-authentication for details. Hope that helps!
Here's an idea to get package managers like pip
to work behind a PAC network.
Find your PAC file, and open it to find out what the actual proxy server is. Then define the HTTP_PROXY
and HTTPS_PROXY
environment variables, giving them a value following the pattern http://user:password@proxy-host:port
. pip
should honour this environment variable. This way, by specifying an actual proxy, you avoid the problem of trying to get pip
to recognize PACs.
The username and password in that environment variable will only work with proxies that require Basic authentication.
Hi, thanks.
This is what I use in R:
Sys.setenv(http_proxy = "http://user:pwd@FGProxy1:3128") Sys.setenv(HTTPS_PROXY = "http://pwd@FGProxy1:3128")
And few more additional lines as per curl and httr package and it works.
However, in python:
I thought the following python code would work, but it did not, maybe because i have not specified my proxy (FGProxy1:3128) here:
from pypac import PACSession from requests.auth import HTTPProxyAuth session = PACSession(proxy_auth=HTTPProxyAuth('login', 'pwd'))
In addition, simply entering the below code in the text editor of anaconda (spyder) and trying to install "pip install gc" in command prompt failed.
HTTP_PROXY = "http://user:pwd@FGProxy1:3128" HTTPS_PROXY = "http://user:pwd@FGProxy1:3128"
Please help! :)
Thank you.
The Python equivalent of your R example is:
import os
os.environ['HTTP_PROXY'] = 'http://user:pwd@FGProxy:3128'
os.environ['HTTPS_PROXY'] = 'http://user:pwd@FGProxy:3128'
However, in order for pip
to pick up these environment variables, you need to set them outside of Python. On Windows, this is done in System > Environment Variables.
Your code example using PyPAC should work. What error does it return? Please share the proxy-authenticate
header of the error response object.
from pypac import PACSession from requests.auth import HTTPProxyAuth session = PACSession(proxy_auth=HTTPProxyAuth('login', 'pwd'))
Executed the above code in text editor.
Hi, I get the following error when I try installing implicit module.
pip install implicit ### in command prompt
Collecting implicit
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000001BA6EA2F8D0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed',)': /simple/implicit/
The code you run in Python does not affect the environment that pip
runs in. They're separate contexts. I don't think I can help you further than the instructions in my last comment.
Hi:
I added the pypac module, and ran the following in ipython console of anaconda(spyder):
from pypac import PACSession
What do I do next if i need to "pip install implicit"?
Still not clear how to go about downloading modules in anaconda by getting past pacs. Normally when i am websurfing i always have to enter user and password for proxy.
Is pypac the right way?
Thank you so much for your help. This is very frustating! :-)
Best regards, Sagar