5

I'm trying to install a Python pip package on Windows 10. Unfortunately, the proxy at my work is giving me trouble.

Things I've tried:

  1. python -m pip install --proxy "http://sam.s1:1234@proxy.det.nsw.edu.au:8080"
  2. python -m pip install --proxy http://sam.s1:1234@proxy.det.nsw.edu.au:8080
    1. & 2. with the protocol changed to https
    1. & 2. omitting the protocol, eg: python -m pip install --proxy sam.s1:1234@proxy.det.nsw.edu.au:8080
  3. set HTTP_PROXY=sam.s1:1234@proxy.det.nsw.edu.au:8080 set HTTPS_PROXY=%HTTP_PROXY% set FTP_PROXY=%HTTP_PROXY%
  4. Editing the proxy address for the HTTP_PROXY env variable in the same way described in steps 1 to 4.
  5. Creating a pip.ini file at %APP_DATA%/pip/ with the following contents:

[global] proxy = "http://sam.s1:1234@proxy.det.nsw.edu.au:8080" trusted-host = pypi.python.org

  1. Editing the proxy address in the pip.ini file in the same way described in steps 1 to 4.

They all give me similar errors such as:

Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002A6F091B080>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',))': /simple/django/

and

Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002142813B128>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/django/

and

Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required',))': /simple/django/

Although sorting out once and for all how to download packages though the proxy would be nice, I'll settle for instructions on any methods that circumvent the proxy entirely, like downloading the package and compiling from source (I usually use Ubuntu, so I have no idea how to do this type of thing on Windows).

Other information:

  • The proxy is configured via a pac script
  • The package I'm currently trying to install is Django, but there will probably be others in the future.
  • I installed pip when I installed Python 3.6.3 (via the checkbox that says something like, do you also want to install pip as well as Python).
  • I know that pip is grabbing the settings from the .ini file, since I can change the output of $ pip list by setting a value for [list].
5
  • 1
    I have no idea about the proxy thing, but you can download Python packages from PyPI and install them with pip (no need to compile from source in most cases, and definitely not with Django). You can get Django from here: pypi.python.org/pypi/Django/1.11.7.
    – user8651755
    Nov 6, 2017 at 2:09
  • Interesting, I've never used PyPy before. Is it as simple as downloading the package and then pointing pip to the to the file somehow? Like: $ python -m pip install Django-1.11.7.tar.gz
    – Sam
    Nov 6, 2017 at 2:33
  • That's exactly how you'd do it. Just to clarify, PyPI is the Python Package Index while PyPy is an alternative implementation of Python.
    – user8651755
    Nov 6, 2017 at 2:35
  • Oh, haha. Thanks for the clarification, I did actually just spend a few minutes looking at PyPy in confusion. I tried your suggestion, it tries Collecting pytz (from Django==1.11.7), which seems to be a timezone package Django requires, and then fails because of the proxy thing again. At least, with your way I can wait for it to fail installing a dependency, download and install the dependency through PyPI, then rinse and repeat. Not ideal, but nothing else seems to work.
    – Sam
    Nov 6, 2017 at 2:50
  • 1
    Just an update for future people; pytz seemed to be the only dependency that needed to be downloaded, so I did get Django installed by downloading both Django-1.11.7.tar.gz and pytz-2017.3.zip and installing them locally with pip. @Blurp If you want to write your comment as an answer, I'll mark it as correct.
    – Sam
    Nov 6, 2017 at 4:35

1 Answer 1

4

I have no idea about the proxy thing, but you can download Python packages from the Python Package Index (PyPI) and install them with pip. There's no need to compile from source in most cases, and definitely not with Django.

You can download Django here and then install it with pip install <path to downloaded package>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.