ContinuumIO / anaconda-issues

Anaconda issue tracking
646 stars 220 forks source link

HTTP and SSL error with Anaconda API and new environment #3292

Closed WolfDSCoder closed 5 years ago

WolfDSCoder commented 7 years ago

I'm having the same issue as originally posted by @cameronsr in #2648.

I can't create a new environment in Anaconda. It seems the Anaconda API domain setting (currently https://api.anaconda.org) is flagged as an invalid URL.

To try and resolve it, I tried to use " conda install anaconda-clean " from the Anaconda Prompt, but get the same CondaHTTPError shown below.

I also tried uninstalling Anaconda from Win10 Programs and Features, then reinstalling Anaconda from a fresh download. The same issues happened. I can't create an environment. I can't update the preferences for the Anaconda API domain setting.

Not sure what to do next. Thank you for any advice.

.condarc

channels:

conda info:

                platform : win-64
        conda version : 4.3.21
     conda is private : False
  conda-env version : 4.3.21
conda-build version : not installed
        python version : 3.6.1.final.0
      requests version : 2.14.2

error message seen:

CondaHTTPError: HTTP None None for url https://repo.continuum.io/pkgs/free/win-64/repodata.json.bz2
Elapsed: None

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
SSLError(SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),),)

vx1920 commented 5 years ago

Recently I found that my sitecustomize.py (or sitevendor.py) script (see in previous post) to set CONDA_xxx environment variables is working in general somehow, but in Modules\main.c I did see some minor problems: CondaEcosystemModifyModifyDllSearchPath_Init() can't see variables which I did set in sitevendor.py (or in sitecustomize.py). Can somebody modify Modules\main.c\pymain_main() by moving call to CondaEcosystemModifyModifyDllSearchPath_Init() slightly down, to have it immediately after call to pymain_init() or you can move it to the right place inside pymain_init(). I did change it in my computer and everything works just fine now.

P.S. Your conda_build.bat file can't find Visual Studio 2017 when it is installed in "c:\Progs\VStud". I did find workaround by adding VS140COMNTOOLS=C:\Progs\VStud\Common7\Tools environment variable. After that your conda_build.bat decide that I have some old Visual Studio and conda_build.bat calls to Pyton's PCbuild\build.bat. Python's PCbuild\build.bat properly detects VS2017 and build was completed OK.

P.P.S. I still don't understand one simple thing: why don't make so called "activation" only once inside Python.exe (actually in PythonNN.dll) and no more repeat again and again for each of Anaconda items, as you are doing in PythonHome\Scripts folder and crazy staff in so called "menuinst". I think it is main "disagreement".

P.P.P.S. I think I begin to understand why you don't like "internal activation". You already did implement it inside Modules\Main.c as "#ifdef HARDCODE_CONDA_PATHS" with controlling it from OS environment. Everything done in so strange way, that even you probably don't like how it works (as to me: I don't like it). What about re-imlementing it in smarter way using Python's sys._xoptions and enable all these new "xoptions" from sitevendor.py shipped with Anconda. Instead of hardcoded DLL search path you can properly set it in sitevendor.py into sys._xoptions['xdll_path'] in any way, same way as site.py doing it for sys.path to search Python modules. You can use additional options, if you need (like "xdll_enable", "xdll_mode" and so on). Modification in main.c going to be simple: no more #ifdef HARDCODED, instead of _wgetenv() you are using config_get_options(config, "xdll_option_name"). Implementation of "xdll" options can be merged into Python core (everything is disabled by default), no more crazy "recipe" with patching Python's core source. CondaEcosystemModifyModifyDllSearchPath_Init() should be renamed as pymain_init_xdll() and moved to the end of pymain_init(). In general: CondaEcosystem should be called something like PythonXDLL (I mean code inside Modules\main.c).

therahulmanocha commented 5 years ago

We're working to debug this. It's very subtle and involves differences between the base env and any other envs. Here's what we've found:

  • Install miniconda (with python 3.7)
conda create someenv_36 python=3.6
conda activate someenv_36
conda install imagesize

You should get the HTTPError here. Sometimes it takes a few seconds to stop working, but when the child env doesn't match the base env, it does break soon after activating the child env, if not immediately.

If you then reactivate the base env:

conda activate
conda install imagesize -n someenv_36

This works. In addition, if the child env python version matches the base env:

conda create someenv_37 python=3.7
conda activate someenv_37
conda install imagesize

This also works.

This is a sweet little hack to this bug and it works fine.

suissemaxx commented 5 years ago

I faced the same problem on Mac OS X and with Miniconda. After trying many of the proposed solutions here and on SO for hours I found that I needed to correctly set Condas environment to use the Root certificate that my company provided rather than the generic ones that Conda provides.

Here is how I solved it:

  1. Open Chrome, got to any website, click on the lock icon on the left of the URL. Click on «Certificate» on the dropdown. In the next window you see a stack of certificates. The uppermost (aka top line in window) is the root certificate, e.g. Zscaler Root CA in my case, yours will very likely be a different one.
  2. Open Mac OS keychain, click on «Certificates» and choose among the many certificates the root certificate that you just identified. Export this to any folder of your choosing.
  3. Convert this certificate with openssl: openssl x509 -inform der -in /path/to/your/certificate.cer -out /path/to/converted/certificate.pem
  4. For a quick check set your shell to acknowledge the certificate: export REQUESTS_CA_BUNDLE=/path/to/converted/certificate.pem
  5. To set this permanently open your shell profile (.bshrs or e.g. .zshrc) and add this line: export REQUESTS_CA_BUNDLE=/path/to/converted/certificate.pem. Now exit your terminal/shell and reopen. Check again.

You should be set and Conda should work fine.

li-xuesong commented 4 years ago

I have solved this "CondaHTTPError: HTTP 000 CONNECTION FAILED for url....". For my case it's to do with the company proxy setting.

Detailed error message: CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.anaconda.com/pkgs/main/win-64/current_repodata.jsonElapsed: An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team. ConnectTimeout(MaxRetryError("HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/main/win-64/current_repodata.json (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x000001B79FFE3278>, 'Connection to repo.anaconda.com timed out. (connect timeout=9.15)'))"))

Solution:

To configure proxy. This would allow you to install packages.

Notice URL is http (not https) for both http_proxy and https_proxy. The name has https but the url does not.

the "http://proxy-XX:XXX" need to be the route proxy of your company.

All the best!

ghost commented 4 years ago

Solution: To configure proxy. This would allow you to install packages.

Start menu search for “env” Select “Edit Environment Variables for your account” Press “New..” and add two variables “http_proxy” and “https_proxy” both with the same value http://proxy-XX:XXX

Notice URL is http (not https) for both http_proxy and https_proxy. The name has https but the url >does not.

the "http://proxy-XX:XXX" need to be the route proxy of your company.

All the best!

This solved it for me! After trying ALL the other things. I'm on a company network with proxy.

Thanks alot @li-xuesong !! 👍

adithyaonline commented 4 years ago

For folks behind a corporate/university network who are still facing issues with this,

this worked for me :

  1. downloading the root certs from the browser as detailed here: https://stackoverflow.com/a/50486128
  2. the certs I downloaded were in DER encoding, and for some reason, I couldn't get them to work with conda. so I had to convert them to PEM and merge them all into a single PEM file. guide : https://support.ssl.com/Knowledgebase/Article/View/19/0/der-vs-crt-vs-cer-vs-pem-certificates-and-how-to-convert-them
  3. conda config --set ssl_verify /path/to/certs.pem OR conda config --set ssl_verify True and set REQUESTS_CA_BUNDLE=/path/to/certs.pem
ZhixuanChang commented 2 years ago

I met the same question in signing in to anaconda.org in navigator. And I resolved this by closing my network proxy.