Using pip behind proxy

Pip is a great tool. It supports batched dependencies, normal packages, subversion trees, mercurial, git, with http, https, ssh.. Glorious! It’s currently my virtualenv building tool of choice:

This is fine as a setup on my development machine, where I have no explicit proxy. However, sometimes I’m in a more restrictive environment, with an authenticated proxy and here pip doesn’t look too useful, at least initially.

Getting subversion out

Some of my repositories are on subversion, accessible with ssh. The process of getting subversion out through a proxy is easy and well documented. In your ~/.subversion directory, edit the proxy settings:

Of course, you can leave e.g. the port to use a default port or the user/password if the proxy does not require authentication. My proxy does require all items.

Getting git/mercurial out

I’ve been looking especially for git proxy-ing, and I’ve found several suggestions, from usingnetcat or transconnect ssh (link no longer valid at to hacking the git code and using git config command. All options were more or less successful and failed for my setup. During my net wanders, I’ve read a comment to the line that git can use 3 protocols for communication: git (d’oh!), http and https.

Since most of the above were referring to getting git-based connection to proxies, I figured that I should try http and see what happens. And, as far http proxy is concerned, UNIX is pretty uniform: Either you have a http_proxy environment variable, or you have command line argument/flag denoting it. Since git didn’t look like having the command line option, I set up:

and ran a git command. It worked! Then I ran a mercurial command. It worked too!

The setting is the same for the https variant:

Of course, if https proxy is not permitted, you might need to go for another option.

6 thoughts on “Using pip behind proxy

    • Well, this might fork for most cases. Unfortunately, it doesn’t really propagate the proxy settings to everything. I have an odd configuration with git, mercurial and subversion.

Comments are closed.