Loading...

Using Proxy for Python on Windows

Using Python on Windows is not my first choice but if you have to, here are some recipes how to use pip behind a proxy. This post assumes that you are using CNTLM as running proxy.

Upgrade pip

python -m pip install --upgrade pip --proxy http://localhost:3128
Collecting pip
  Downloading pip-10.0.0-py2.py3-none-any.whl (1.3MB)
    100% |################################| 1.3MB 514kB/s
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.0```

Install docker-py

pip install docker-py --proxy http://localhost:3128
Collecting docker-py
  Downloading docker_py-1.10.6-py2.py3-none-any.whl (50kB)
    100% |################################| 51kB 265kB/s
Collecting requests!=2.11.0,>=2.5.2 (from docker-py)
  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
    100% |################################| 92kB 1.2MB/s
Collecting backports.ssl-match-hostname>=3.5; python_version < "3.5" (from docker-py)
  Downloading backports.ssl_match_hostname-3.5.0.1.tar.gz
Collecting ipaddress>=1.0.16; python_version < "3.3" (from docker-py)
  Downloading ipaddress-1.0.22-py2.py3-none-any.whl
Collecting docker-pycreds>=0.2.1 (from docker-py)
  Downloading docker_pycreds-0.2.2-py2.py3-none-any.whl
Collecting websocket-client>=0.32.0 (from docker-py)
  Downloading websocket_client-0.47.0-py2.py3-none-any.whl (200kB)
    100% |################################| 204kB 1.5MB/s
Collecting six>=1.4.0 (from docker-py)
  Downloading six-1.11.0-py2.py3-none-any.whl
Requirement already satisfied: urllib3<1.23,>=1.21.1 in c:\dev\tools\python27\lib\site-packages (from requests!=2.11.0,>=2.5.2->docker-py) (1.22)
Collecting idna<2.7,>=2.5 (from requests!=2.11.0,>=2.5.2->docker-py)
  Downloading idna-2.6-py2.py3-none-any.whl (56kB)
    100% |################################| 61kB 1.3MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests!=2.11.0,>=2.5.2->docker-py)
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |################################| 143kB 1.9MB/s
Collecting certifi>=2017.4.17 (from requests!=2.11.0,>=2.5.2->docker-py)
  Downloading certifi-2018.1.18-py2.py3-none-any.whl (151kB)
    100% |################################| 153kB 1.9MB/s
Installing collected packages: idna, chardet, certifi, requests, backports.ssl-match-hostname, ipaddress, six, docker-pycreds, websocket-client, docker-py
  Running setup.py install for backports.ssl-match-hostname ... done
Successfully installed backports.ssl-match-hostname-3.5.0.1 certifi-2018.1.18 chardet-3.0.4 docker-py-1.10.6 docker-pycreds-0.2.2 idna-2.6 ipaddress-1.0.22 requests-2.18.4 six-1.11.0 websocket-client-0.47.0