Tuesday, December 12, 2017

Using Python's pip behind Firewall (on Windows)

To use python behind a firewall that uses ntlm authentication we will use ntlm maps local proxy.

So here are the steps:

1. Download and install ntlm maps 
   (local proxy that will handle the authentication with our corporate proxy)
    http://ntlmaps.sourceforge.net/

2. Configure server.cfg of the ntlm maps,  change the following
      LISTEN_PORT:5865
      PARENT_PROXY:XXXX.XXXX.XXXX.XXXX
      PARENT_PROXY_PORT:XXXX
      NT_DOMAIN:xxxxx.xxx
      USER:xxxxxxxxxxx
      PASSWORD: 

   If we leave the password blank it will ask us for it at run-time.

3. if ntlm maps does not run - then some dlls are missing those are
    -MSVCP71.DLL
    -MSVCR71.DLL
    Copy then into SysWOW64 if needed (on 64 bit system) or into (System32 on 32 bit system)

4. run the ntlm maps

5.  download and install python
       https://www.python.org/downloads/
       https://www.python.org/ftp/python/2.7.14/python-2.7.14.msi

6. open command prompt (cmd) and enter:
      set http_proxy=localhost:5865

7. use pip to download and install plugins
    -cx_Oracle-doc
    pip --proxy http://127.0.0.1:5865 install cx_Oracle --upgrade
    -Jinja2-2.7.2
    pip --proxy http://127.0.0.1:5865 install Jinja2 --upgrade
    -mechanize-0.2.5
    pip --proxy http://127.0.0.1:5865 install mechanize --upgrade
    -beautifulsoup4
    pip --proxy http://127.0.0.1:5865 install beautifulsoup4 --upgrade

No comments:

Post a Comment