Wez
Wez

Reputation: 31

How to configure a proxy into GitBash environment on windows 10

I installed Python 3.7.3 on windows 10, but I can't install Python packages via PIP in Gitbash (Git SCM), due to my company's internet proxy.

I tryed to create environment variables for the proxy via the following, but it didn't work:

I found a temporary solution that works for me: inserting the following aliases into the .bashrc file:

The above is working but I am looking for a nicer solution so that I don't need to set aliases for every command I use. I was thinking about something like an environment variable but didn't found out how to set it up on a windows' git bash environment yet.

Do you have an idea on how to do it?

Upvotes: 3

Views: 6602

Answers (2)

VonC
VonC

Reputation: 1323553

First, you don't need Git bash to pip install Python modules.
Only Git path (to use linux-like commands, plus curl, even though it is available on recent Windows 10), from a regular CMD, with a simplified PATH:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%
set PH=C:\path\to\Python37
set PATH=%PH%;%PH%\Scripts

Second, you can pip install in a corporate environment, provided:

  • you access your proxy through px, an HTTP proxy server to automatically authenticate through an NTLM proxy
  • you use and trust mirror alternatives for pip module sources.

Regarding genotrance/px, simply run the service with px --proxy=my.company.prpxy:<port> --save --config=/path/to/your/px.ini

No need to enter your credentials (Windows log/password): the proxy uses your current login session.

Set your environment variable to reference that proxy:

set HTTP_PROXY=http://localhost:3128
set HTTPS_PROXY=http://localhost:3128

Then, this will work:

λ pip install -i http://pypi.mirror.frontiernet.net/simple --trusted-host pypi.mirror.frontiernet.net "ansible-tower-cli==3.2.1" --force-reinstall
Looking in indexes: http://pypi.mirror.frontiernet.net/simple
Collecting ansible-tower-cli==3.2.1
  Downloading http://pypi.mirror.frontiernet.net/packages/98/39/566f2dc628917e28d6600607cd0a533b9ed02395297363b2db827e59e488/ansible-tower-cli-3.2.1.tar.gz (153kB)
    100% |████████████████████████████████| 163kB 107kB/s

(Use any pypi mirror not blocked by your company=

Upvotes: 1

user3313834
user3313834

Reputation: 7827

first you need to check if the corp Proxy you are behind is NTLM or not, check this https://stackoverflow.com/a/12476379/3313834 may help.

Upvotes: 1

Related Questions