简体   繁体   中英

pip behind a company proxy - workaround?

My work uses a proxy with a .pac configuration file to connect to the internet. This is giving me huge headaches to make things like git work (managed to make it work), now I'm trying to configure Python, I installed it (Windows) and now I'm trying to get some libraries like request or lxml , but pip can't connect to internet

'Connection aborted.', gaierror(11004, 'getaddrinfo failed'))'/simple/lxml/

I know is a proxy problem, I don't think I can make it work, so my question is:

Is there any way of downloading the libraries from a webpage and then install them manually?

I found some of them at https://pypi.python.org but I want to be able to download a library at home, get the files and then install it at work

Install the packages from PyPI as follows:

  • Download the package
  • Unzip it
  • Go into the folder with setup.py
  • type in python setup.py install (if not stated otherwise in the installation instructions)

Another way is to use the Windows binaries for Python which can be found at ~gohlke . Install the downloaded wheels via pip install some-package.whl .


A solution for your proxy issue could be to look up the IP addresses used by the load-balancer of the proxy (usually listed in the .pac file, try to open it directly in a web browser) and set one of the proxy IPs manually in the Internet Explorer settings and in your pip or Python settings. Usually the company IT rules reset the proxy settings quite often, so you have to do this every time, you hit the proxy error.

Run inetcpl.cpl ,4 to open the Internet Explorer settings directly on the tab you need to set the proxy.

除非您有代理,否则最好的方法是从互联网下载软件包并从那里构建,如其他答案所述,但如果您有公司代理,这是常见且速度更快的,您可以使用pip install pakg_name --proxy http://proxy.name它将通过备用路径下载包。

I solved the problem with PIP in Windows using Fiddler . After downloading and installing, do the following:

"Rules" => click "Automatically Authenticate"

Just open your prompt and use https://github.com/pypa/pip/issues/1182
Search for "voltagex" (commented on 22 May 2015)

View the .pac file content. Usually it's just simple if/else to handle different domains like the company's or local, LAN...

Find the actual proxy address (if they are using Squid then the default port would be 3128). Then export the env http_proxy , https_proxy with the proxy address.

I am working under a proxy too and sometimes it drives me crazy. But now it's all works for me, at least for Python.

Workaround proposition: If you want to upgrade pip or install a wheel, but can't get to it from the command line because of company's proxy or some certificate lacking, but you have access to the Internet from a browser - download the package for your operating system and python version manually from pypi.org, put that .tar.gz or .whl or .exe on C:> and then install it, for example:

C:\>pip install --upgrade pip-19.2.1-py2.py3-none-any.whl

Or, if you download a specific package that trys to pull more packages from the Internet (like wxPython implies having numpy, pillow and six preinstalled), download manually those packages also and install them first and then that specific package,eg:

C:\>pip install six-1.12.0.tar.gz
Pillow-6.1.0.win-amd64-py3.7.exe (Run as administrator)
C:\>pip install numpy-1.17.0-cp37-cp37m-win_amd64.whl
C:\>pip install wxPython-4.0.6-cp37-cp37m-win_amd64.whl

Also, run command line as an Administrator if you can.

found a workaround.

Step 1.
On a personal computer which is not restricted by a company firewall use the command "pip download packagename". This will download all the .whl files that are needed as dependencies as well as the package .whl file on the hardisk.

Step 2.
Transfer these files via email or USB (if enabled) to your company computer and store it in any folder on C drive.

Step 3.
Install the .whl file one by one on your company computer by using the command
pip install C:/foldername/nameofwhlfile.whl ,
you might have to follow a particular order because the files could have dependencies on each other. for eg if you install A.whl you may get a error message that package B is missing which means you first need to run the command
pip install C:/foldername/B.whl

...this way you can install any package behind firewall !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM