Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use pip with socks proxy?

Tags:

macos

pip

proxy

I'm using ssh -D to create a socket proxy and want to know how to use pip(or easy_install) with it? I find this question but that's an http proxy.

Also, please give me a solution works under OS X. (I tried proxifier, it works with pip install, but not sudo pip install)

like image 837
can. Avatar asked Apr 07 '14 14:04

can.


4 Answers

Easiest method, also works on many OS's:

pip install pysocks
pip install <yourpacakge> --proxy socks5:127.0.0.1:8123

Substitute socks4, and your own ip/port as needed.

like image 200
Erik Aronesty Avatar answered Oct 14 '22 17:10

Erik Aronesty


Use socks proxifier, for example proxychains.

Command pip will be like proxychains pip install package_name.

Or use another proxifier.

like image 32
Pavel Patrin Avatar answered Oct 14 '22 18:10

Pavel Patrin


For CentOS, you can use privoxy to convert socks5 proxy to http proxy.

yum install privoxy

Then edit /etc/privoxy/config, at the end of the file, add:

forward-socks5 / 127.0.0.1:1080 .

It will convert socks5 proxy from 1080 to http proxy 8118. Then you can specify the proxy in your pip config file:

[global]
proxy = 127.0.0.1:8118

DO NOT use polipo, as it is already deprecated.

like image 32
Zhang Buzz Avatar answered Oct 14 '22 18:10

Zhang Buzz


Nevermind, --proxy seems to work with http(s) proxy only.

From "pip --help"

--proxy <proxy>             Specify a proxy in the form
                          [user:passwd@]proxy.server:port.

Edit: I finally gave up sock proxy and run a java http proxy (jhttp2.sourceforge.net/‎) on my remote machine and use ssh -L port:localhost:port to forward the port to the remote machine and use that http proxy.

like image 26
user3003714 Avatar answered Oct 14 '22 17:10

user3003714