3

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

bastelflp
  • 9,362
  • 7
  • 32
  • 67
Gonzalo Hernandez
  • 727
  • 2
  • 9
  • 25

6 Answers6

5

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.

bastelflp
  • 9,362
  • 7
  • 32
  • 67
  • He does not know how to install libraries without pip. – Elis Byberi Nov 08 '17 at 22:20
  • The wheels from ~gohlke can just be installed via `pip install some-package.whl`. I added it to the answer. – bastelflp Nov 08 '17 at 22:22
  • 1
    Tell him the only way. Start from [https://pypi.python.org](https://pypi.python.org) and continue with `python setup.py install` **There should be one-- and preferably only one --obvious way to do it.** – Elis Byberi Nov 08 '17 at 22:25
  • You are right. I edited the answer to include this as preferred solution. – bastelflp Nov 08 '17 at 22:36
2

The best way to do this unless you have a proxy is to download the package from the internet and build from there as the other answers mentioned, but if you have a company proxy, which is common and much faster, you can use pip install pakg_name --proxy http://proxy.name which will download the package through the alternate path.

1

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)

zx485
  • 28,498
  • 28
  • 50
  • 59
Lucius Matos
  • 131
  • 2
  • 5
  • Thanks! I wasn't sure what to do with Fiddler, once installed and set to "Automatically Authenticate". It seems it's enough to just have it open in the background. Then go back to command prompt and `pip install packagename` normally. – Roberto Dec 03 '18 at 13:52
1

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.

hunzter
  • 554
  • 4
  • 11
0

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,e.g.:

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.

macok
  • 121
  • 1
  • 4
-1

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 !

deHaar
  • 17,687
  • 10
  • 38
  • 51