22

I'm having trouble working with Anaconda behind a proxy at work.

When I have have the following environment variables:

http_proxy: http://domain\username:password@corp.com:8080
https_proxy: https://domain\username:password@corp.com:8080

or just

http_proxy: http://server\username:password@corp.com:8080

set up then git works. But Anaconda does not work. I'm trying to run

conda update conda

and I get:

Could not connect to https://repo.continuum.io/pkgs....
Could not connect to https://repo.continuum.io/pkgs....

Does Anaconda not work with http? and requires an https proxy? Because I'm thinking my company may not have an https proxy server setup (I've only seen them use http). or sometimes I get the error:

File "c\Anaconda2\", line 340, in wait
    waiter.acquire()
KeyboardInterrupt
Could not connect to https://repo.continuum.io/pkgs....
Could not connect to https://repo.continuum.io/pkgs....

I'm using Windows 7.

Alo
  • 974
  • 2
  • 8
  • 24

11 Answers11

49

you need to create a .condarc file in you Windows user area:

C:\Users\<username>\

The file should contain:

channels:
- defaults

# Show channel URLs when displaying what is going to be downloaded and
# in 'conda list'. The default is False.
show_channel_urls: True
allow_other_channels: True

proxy_servers:
    http: http://proxy.yourorg.org:port
    https: https://proxy.yourorg.org:port


ssl_verify: False
ctrl-alt-delete
  • 3,696
  • 2
  • 24
  • 37
  • Thank you @toasteez , but this solution is not working. I followed your advice exactly, but when I run conda update conda to test, I get an error message telling me "Could not find a proxy for https. See url....." – Alo May 03 '16 at 16:54
  • 1
    Try using the same http address http://proxy.yourorg.org:port for both. Also update your local environment variables for HTTP_PROXY and HTTPS_PROXY to the same. Most organisations have a proxy with a wpad.dat file and an additional proxy address. You need to find the correct one. – ctrl-alt-delete May 04 '16 at 06:56
  • Thanks @toasteez . My environment variables for HTTP_PROXY and HTTPS_PROXY are set to http://username:pass@proxy.company.org:8080 and the same for HTTPS_PROXY. and I was positive that they were fine (or at least HTTP_PROXY), because I can use git to pull and push now. But Anaconda commands are not going through. Where can I find the wpad.dat file? Maybe I should be using a different HTTPS_PROXY? – Alo May 04 '16 at 16:36
  • 1
    wpad.dat is usually in IE explorer LAN proxy settings. You can copy the path into the browser to view the file. It may show the proxy. I would point the .condarc https entry to the http. https: http://proxy.yourorg.org:port Note that if you find the correct proxy you should be able to make this work without user:pass. This is really bad practice and your network admin will probably spot it. – ctrl-alt-delete May 06 '16 at 07:55
  • @Alo also you might have to request that the firewall team open access on the https to the repo: https://repo.continuum.io/pkgs/free/win-64/ – ctrl-alt-delete May 06 '16 at 07:57
  • it worked! It was my fault I did not read your response carefully enough. On the https: it was http://blahblah:blah. I was doing https://blahblah:blah. Thanks! – Alo May 09 '16 at 21:31
  • 1
    `https: http://proxy.yourorg.org:port` should be `https: httpS://proxy.yourorg.org:port` (note the S in http) – Boern May 18 '17 at 14:13
  • Turning off SSL verification could potentially be catastrophic. I personally would find another way. – spacedustpi Aug 03 '18 at 00:04
  • This did not work for me at all, the conda commands stopped executing – Paul Oct 22 '18 at 16:14
  • above solution worked for me after removing http// and https//(keeping ssl_verify: False or True both worked). – Lalit kumar Aug 31 '22 at 07:14
6

After a lot of trial and error, we finally got ours working with the following syntax (no "http://") in the .condarc files (we had two such files, one in Users folder, and another in the actual User's folder).

proxy_servers:
    http: proxyserver.org:portNumber
    https: proxyserver.org:portNumber

The proxy server had to make an exception to anaconda.org as well as anaconda.com. IMPORTANT!

DrWhat
  • 2,360
  • 5
  • 19
  • 33
  • 3
    This has plagued me for years, thanks for the syntax tip. The "http://" was killing it. – Jon Sep 15 '21 at 17:28
  • To find your proxy, on Windows 10, try `Settings -> Network & Internet -> Proxy -> Address + Port`, that for `proxyserver.org:portNumber` in this answer. – Vladislav Povorozniuc Feb 28 '23 at 21:02
5

If the above solutions didnt work for you, you can try this.

Go to your PC settings and then to proxy. Just give the proxy setting globally for your pc. When I did it, it worked for me.

enter image description here

Sadman Amin
  • 429
  • 4
  • 7
4

I went on to add HTTP_proxy and HTTPS_proxy in the environment variable. The format used was "username:password@proxy_name:port". I then reopened Anaconda prompt. Type "set" to verify the added variables are present in Anaconda environment. Now you can type "spyder" in the Ananconda prompt. This setting worked for me.

Initially I had tried setting the ".condarc file with the proxy parameters and tried "conda update conda" to no luck.

Rom098
  • 2,445
  • 4
  • 35
  • 52
2

The above solution of modifying .condarc doesn't work for me. However I succeed by updating the environment variables in Advanced System Settings in the format https://user:pass@corp.com:8080.

If your password contains special characters, you need escape them as described in Percent-encoding reserved characters , on Wikipedia. https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters

Mina HE
  • 1,666
  • 2
  • 11
  • 4
  • Thank you very much, Reserved characters list for special characters `! - %21 # - %23 $ - %24 % - %25 & - %26 ' - %27 ( - %28 ) - %29 * - %2A + - %2B , - %2C / - %2F : - %3A ; - %3B = - %3D ? - %3F @ - %40 [ - %5B ] - %5D` – Ashwaq Dec 19 '19 at 08:32
2

The below worked for me to permanently set my proxies for Anaconda:

Go to C:/ProgramData/Anaconda3/etc/

If it doesn’t already have a conda folder, create it.

If it doesn’t already have the folders activate.d and deactive.d, create them.

Also create env_vars.bat in both folders. Your end structure should look like the snapshot below:

enter image description here

In env_vars.bat in activate.d, paste the following (change it to your own proxies):

set HTTP_PROXY=http://xx.xx.x.xx:xxxx/
set FTP_PROXY=http://xx.xx.x.xx:xxxx/
set HTTPS_PROXY=https://xx.xx.xxx.xx:xxxx/

In env_vars.bat in deactivate.d, paste the following (leave the variables blank):

set HTTP_PROXY=
set FTP_PROXY=
set HTTPS_PROXY=

Close and reopen your Anaconda Prompt to activate the changes.

yl_low
  • 1,209
  • 2
  • 17
  • 26
  • hooray! this is what work for me. In my case Aanconda is installed for me only, so the bat file has to be created in C:\Users\xxxxxxx\AppData\Local\Continuum\anaconda3\etc\conda\activate.d – Mickaël M. Mar 06 '19 at 10:46
2

See my answer in another post:

The best way I settled with is to set proxy environment variables right before using conda or pip install/update commands. Simply run:

set HTTP_PROXY=http://username:password@proxy_url:port

For example, your actual command could be like

set HTTP_PROXY=http://yourname:your_password@proxy.your_company.com:8080

If your company uses https proxy, then also

set HTTPS_PROXY=https://username:password@proxy_url:port

Once you exit Anaconda prompt then this setting is gone, so your username/password won't be saved after the session.

I didn't choose other methods mentioned in Anaconda documentation or some other sources, because they all require hardcoding of username/password into

  • Windows environment variables (also this requires restart of Anaconda prompt for the first time)
  • Conda .condarc or .netrc configuration files (also this won't work for PIP)
  • A batch/script file loaded while starting Anaconda prompt (also this might require configuring the path)

All of these are unsafe and will require constant update later. And if you forget where to update? More troubleshooting will come your way...

Frank Wang
  • 381
  • 3
  • 7
1

I just added a slash after my proxy config entries in .condarc and it magically started working. Everything from above was useless.

BTW I use a CNTLM local proxy on my system to make the kerberos auth, so I do not need to config the credentials in .condarc so visibly.

proxy_servers:
    http: http://proxy.yourorg.org:port/
    https: http://proxy.yourorg.org:port/
  • In the .condarc file, https: http://proxy.etc worked for me - without the 's' even though it is for the https setting. My answer above works in our windows environment, but not in a server environment - where it throws an error that the scheme (http:// / https://) is missing. Adding the schemes with https: https://proxy.yourorg.org:port doesn't work, but https: http://proxy.yourorg.org:port/ miraculously does. – DrWhat Mar 04 '22 at 08:07
  • I've read about indents being relevant, and quotes. Having struggled to get two environments working behind the same proxy, my general advice would be to try every possible syntax mentioned in stack exchange. It's not too hard, just edit .condarc, save, and try to install a package in cmd (there is no need to close and open anything). – DrWhat Mar 04 '22 at 08:12
0

Worked for me with certificate yourcertname.pem: https://aafaqueabdullah.wordpress.com/2017/04/10/ssl-authentication/

itsergiu
  • 662
  • 6
  • 11
0

This method worked for me:

Copy files libcrypto-1_1-x64.dll and libssl-1_1-x64.dll from the directory ./Anaconda3/Library/bin/ to ./Anaconda3/DLLs.

Hope it answers your question

Edward Lu
  • 11
  • 1
  • 1
0

The below solutions have worked for me:

  1. Open Anaconda Prompt
  2. Before running any pip or conda command, execute below command:

set HTTPS_PROXY=proxy.yourorg.domain:portnumber

set HTTP_PROXY=proxy.yourorg.domain:portnumber


  1. Now you can execute any pip and/or conda command to install/uninstall your required packages.
  2. That's it, it should work for you as well (hopefully)