Reputation: 10971
I am trying to use pip behind a proxy at work.
One of the answers from this post suggested using CNTLM. I installed and configured it per this other post, but running cntlm.exe -c cntlm.ini -I -M http://google.com
gave the error Connection to proxy failed, bailing out
.
I also tried pip install -–proxy=user:pass@localhost:3128
(the default CNTLM port) but that raised Cannot fetch index base URL http://pypi.python.org/simple/
. Clearly something's up with the proxy.
Does anyone know how to check more definitively whether CNTLM is set up right, or if there's another way around this altogether? I know you can also set the http_proxy
environment variable as described here but I'm not sure what credentials to put in. The ones from cntlm.ini
?
Upvotes: 295
Views: 788071
Reputation: 1
Setting HTTP_PROXY TO proxyserver:proxyport without the http:// or https:// in the windows environment variables worked for me. After setting it like that I do not need to include the proxyserver and the proxyport in the pip install command.
Upvotes: 0
Reputation: 2911
With Ubuntu I could not get the proxy option to work as advertised – so the following command did not work:
sudo pip --proxy http://web-proxy.mydomain.com install somepackage
But exporting the https_proxy
environment variable (note it's https_proxy
not http_proxy
) did the trick:
export https_proxy=http://web-proxy.mydomain.com
Then:
sudo -E pip install somepackage
Upvotes: 281
Reputation: 1128
2022 for windows:
I know there are many answers and nearly every other question with pip
and behind a proxy
is refering to this question:
So in my opinion it is on the one hand the proxy thing, which is answered in the questions below.
pip install --proxy=https://<windowsuser>:<pw>@<proxy>:port package
After that you have to deal with the SSL certificates. You have to add the trusted sources. Usually they are standing in the Error message
. For example: ERROR: .... host='files.pythonhosted.org'
And here is my solution for installing for example Django
:
pip install Django --proxy http://windowsuser:password@proxy:port --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org
Upvotes: 2
Reputation: 41
Using pip behind a work proxy with authentification, note that quotation is required for some OSes when specifing the proxy url with user and password:
pip install <module> --proxy 'http://<proxy_user>:<proxy_password>@<proxy_ip>:<proxy_port>'
Documentation: https://pip.pypa.io/en/stable/user_guide/#using-a-proxy-server
Example:
pip3 install -r requirements.txt --proxy 'http://user:[email protected]:1234'
Example:
pip install flask --proxy 'http://user:[email protected]:1234'
Proxy can also be configured manually in pip.ini. Example:
[global]
proxy = http://user:[email protected]:1234
Documentation: https://pip.pypa.io/en/stable/user_guide/#config-file
Upvotes: 4
Reputation: 1104
It was not working for me. I had to use https at work:
pip install --proxy=https://user@mydomain:port somepackage
In order to update, add -U.
Upvotes: 67
Reputation: 1
ex:PORT = 9090
ex:PROXY_SERVER = stackoverflow
USERNAME:your user id
PASSWORD: your password
• sudo pip2 install PACKAGENAME --proxy https://USERNAME:PASSWORD@PROXY_SERVER:PORT/
for Python2.7
• sudo pip3 install PACKAGENAME --proxy https://USERNAME:PASSWORD@PROXY_SERVER:PORT/
for Python3.5
Example:
sudo pip2 install pandas --proxy https://USERNAME:PASSWORD@PROXY_SERVER:PORT/
apt-get
Installationsudo http_proxy=http://USERNAME:PASSWORD@PROXY_SERVER:PORT/ apt-get install PACKAGENAME
Example:
sudo http_proxy=http://USERNAME:YOURPASSWORD@PROXY_SERVER:PORT/ apt-get install tensorrt
sudo http_proxy=http://USERNAME:YOURPASSWORD@PROXY_SERVER:PORT/ apt-get update
Upvotes: 0
Reputation: 51
A simpler approach might be:
$HOME
directory.Copy & paste the following lines under the pip.ini/pip.conf:
[global]
trusted-host = pypi.python.org
pypi.org
files.pythonhosted.org
Upvotes: 0
Reputation: 866
If you are connecting to the internet behind a proxy, there might be problem in running the some commands.
Set the environment variables for proxy configuration in the command prompt as follows:
set http_proxy=http://username:password@proxyserver:proxyport
set https_proxy=https://username:password@proxyserver:proxyport
Upvotes: 3
Reputation: 1552
I could achieve this by running:
pip install --proxy=http://user:[email protected]:3128 package==version
I'm using Python 3.7.3 inside a corporative proxy.
Upvotes: 6
Reputation: 431
If you are using Linux, as root:
env https_proxy=http://$web_proxy_ip:$web_proxy_port pip install something
When you use env it exports the variable https_proxy for the current execution of the command pip install.
$web_proxy_ip is the hostname or IP of your Proxy $web_proxy_port is the Port
Upvotes: 1
Reputation: 2067
Set the following environment variable: export PIP_PROXY=http://web-proxy.mydomain.com
Upvotes: 1
Reputation: 1
for windows go to C:/ProgramData/pip/pip.ini, and set
[global]
proxy = http://YouKnowTheRest
with your proxy details. This permanently configures the proxy for pip.
Upvotes: 0
Reputation: 301
Open the Windows command prompt.
Set proxy environment variables.
set http_proxy=http://user:password@proxy_ip:port
set https_proxy=https://user:password@proxy_ip:port
Install Python packages using proxy in the same Windows command prompt.
pip install --proxy="user:password@proxy_ip:port" package_name
Upvotes: 13
Reputation: 238
$ pip --proxy http://proxy-host:proxy-port install packagename
This is what worked for me on
Upvotes: 21
Reputation: 161
I solved the problem with PIP in Windows using "Fiddler" (https://www.telerik.com/download/fiddler). After downloading and installing, do the following:
"Rules" => click "Automatically Authenticate"
Example: pip install virtualenv -proxy 127.0.0.1:8888
Just open your prompt and use.
https://github.com/pypa/pip/issues/1182 Search for "voltagex" (commented on 22 May 2015)
Upvotes: 0
Reputation: 1676
if you want to upgrade pip by proxy, can use (for example in Windows):
python -m pip --proxy http://proxy_user:proxy_password@proxy_hostname:proxy_port insta
ll --upgrade pip
Upvotes: 5
Reputation: 1397
This worked for me (on Windows via CMD):
pip install --proxy proxyserver:port requests
Upvotes: 26
Reputation: 189
In Ubuntu 14.04 LTS
sudo pip --proxy http://PROXYDOM:PROXYPORT install package
Cheers
Upvotes: 8
Reputation: 637
How about just doing it locally? Most likely you are able to download from https source through your browser
Extract it and go the extracted dir where setup.py is located and call:
C:\mysql-connector-python-2.0.3>python.exe setup.py install
Upvotes: 2
Reputation: 214
This is what works for me:
pip --proxy proxy url:port command package
Upvotes: 1
Reputation: 1531
I am also no expert in this but I made it work by setting the all_proxy
variable in the ~/.bashrc file. To open ~/.bashrc
file and edit it from a terminal run following commands,
gedit ~/.bashrc &
Add following at the end of file,
export all_proxy="http://x.y.z.w:port"
Then either open a new terminal or run following in the same terminal,
source ~/.bashrc
Just setting http_proxy
and https_proxy
variables aren't enough for simple usage pip install somepackage
. Though somehow sudo -E pip install somepackage
works, but this have given me some problem in case I am using a local installation of Anaconda in my users' folder.
P.S. - I am using Ubuntu 16.04.
Upvotes: 2
Reputation: 1179
In Windows 7:
pip install --proxy DOMAIN\user:password@proxyaddress:port package
i.e.:
pip install --proxy BR\neo:[email protected]:8080 virtualenv
Upvotes: 12
Reputation: 1717
Set up invironment variable in Advanced System Settings. In Command prompt it should behave like this :
C:\Windows\system32>echo %http_proxy%
http://username:passowrd@proxy:port
C:\Windows\system32>echo %https_proxy%
Later , Simply
pip install whatEver
should work.
Upvotes: 6
Reputation: 44739
I got the error:
chris@green:~$ sudo http_proxy=http://localhost:3128 pip install django==1.8.8
Downloading/unpacking django==1.8.8
Cannot fetch index base URL http://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement django==1.8.8
No distributions at all found for django==1.8.8
Storing complete log in /home/chris/.pip/pip.log
(The proxy server's port is ssh port forwarded to localhost:3128
).
I had to set both http and https proxies to make it work:
chris@green:~$ sudo http_proxy=http://localhost:3128 https_proxy=http://localhost:3128 pip install django==1.8.8
Downloading/unpacking django==1.8.8
Downloading Django-1.8.8.tar.gz (7.3Mb): 7.3Mb downloaded
Running setup.py egg_info for package django
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
Installing collected packages: django
Running setup.py install for django
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
changing mode of build/scripts-2.7/django-admin.py from 644 to 755
changing mode of /usr/local/bin/django-admin.py to 755
Installing django-admin script to /usr/local/bin
Successfully installed django
Cleaning up...
as http://pypi.python.org/simple/
redirects to https://pypi.python.org/simple
but pip
's error does not tell you.
Upvotes: 2
Reputation: 785
Warning, there is something very bad with the "pip search" command. The search command do not use the proxy setting regardless of the way it's being passed.
I was trying to figure out the problem only trying the "search" command, and found this post with detailed explanation about that bug: https://github.com/pypa/pip/issues/1104
I can confirm the bug remains with pip 1.5.6 on Debian 8 with python 2.7.9. The "pip install" command works like a charm.
Upvotes: 2
Reputation: 350
At CentOS (actually I think all linux distros are similar) run
env|grep http_proxy
and
env|grep https_proxy
check what is the output of those commands (they should contain your proxy addresses).
If the outputs are empty or have incorrect values, modify them, for ex:
export http_proxy=http://10.1.1.1:8080
export https_proxy=http://10.1.1.1:8080
Now try to fetch and install some packages by using pip:
pip --proxy http://10.1.1.1:8080 install robotframework
and actually I have never met the case when it didn't work. For some systems you need to be a root (sudo is not enough).
Upvotes: 2
Reputation: 131
For windows users: if you want to install Flask-MongoAlchemy then use the following code
pip install Flask-MongoAlchemy --proxy="http://example.com:port"**
Upvotes: 4
Reputation: 3235
To setup CNTLM for windows, follow this article. For Ubuntu, read my blog post.
Edit:
Basically, to use CNTLM in any platform, you need to setup your username and hashed password, before using http://127.0.0.1:3128
as a proxy to your parent proxy.
Edit the config and add important information like domain, username, password and parent proxy.
Generate hashed password.
Windows cntlm –c cntlm.ini –H
Ubuntu/Linux cntlm -v -H -c /etc/cntlm.conf
Remove plain text password from the config and replace them with the generated passwords.
To check if working:
Windows cntlm –M http://www.google.com
Ubuntu/Linux sudo cntlm -M http://www.google.com/
For more detailed instructions, see links above.
Update:
Just for completeness sake, I was able to configure and use CNTLM in Windows recently. I encountered a problem during the syncing process of Kindle for PC because of our proxy and installing and configuring CNTLM for Windows fixed that issue for me. Refer to my article for more details.
Upvotes: 77
Reputation: 720
You can continue to use pip over HTTPS by adding your corporation's root certificate to the cacert.pem file in your site-packages/pip folder. Then configure pip to use your proxy by adding the following lines to ~/pip/pip.conf (or ~\pip\pip.ini if you're on Windows):
[global]
proxy = [user:passwd@]proxy.server:port
That's it. No need to use third party packages or give up HTTPS (of course, your network admin can still see what you're doing).
Upvotes: 48
Reputation: 7109
If I have much trouble finding a way through the corporate proxy, I connect to the web through my phone (wireless hotspot if I have wifi, USB tether if not) and do a quick pip install
.
Might not work for all setups, but should get most people by in a pinch.
Upvotes: 13