How can I solve CondaHTTPError in anaconda? - python

I'm using Windows 10 pro(x64) and I have just installed Anaonda 4.3.1
But whenever I try to install a package or update conda, it shows an error like the below.
(d:\Miniconda3) C:\Windows\system32>conda update conda
Fetching package metadata .....
CondaHTTPError: HTTP None None for url <None>
Elapsed: None
An HTTP error occurred when trying to retrieve this URL.
SSLError(SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_read_bytes', 'sslv3 alert bad record mac')],)",),),)
conda config --set ssl_verify False doesn't make any difference either.
I have no problem installing packages using pip.

These errors coming from such abstracting (i.e. with a high level of abstraction) tools are usually really hard to debug from the tool themselves (it requires quite a lot of digging around in the tool's code to pinpoint and finally find the issue); to the extent that in the vast majority of cases, once you've debugged it, you know enough about the tool in question to actually be able to write a patch to solve that problem.
What I would recommend is to first trace how does conda get the metadata it is getting at first (first line of your output). On UNIX I would recommend tcpdump, but on windows I would use wireshark (albeit according to the wikipedia page for tcpdump, it works on windows too).
Once you know what host the package should be obtained from, you can try to understand why it occurs. Namely, the bad record mac error should not occur under normal conditions; i.e. either you have a network problem (try with another network) or there is a server (more likely if conda used to work) or client problem.
To try to debug the SSL issue once you know the host, run:
openssl s_client -connect $host:443 -msg -debug
Where $host is the host you found using tcpdump/wireshark.
Best of luck!
Note: I have not linked wireshark.org in this answer, but instead the wikipedia page for wireshark to prevent supporting bogus security practices 1,2. Please do not edit that link.

Related

How to find out what this error means: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1129)

From a python app attempting to make an HTTPS request I'm hitting an error which I'm struggling to understand:
[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1129)
I presume this is coming from OpenSSL. But besides the handshake failing, it doesn't tell me what the problem is. IE: it doesn't tell me why the handshake failed or what step of it failed.
Various links on google give things to try, but give no reason why they might work. I have tried them but nothing worked so far. Based on these results I have tried:
upgrading certifi
running the certificate install script in mac python install directory
upgrading the python version
Is there any way to get more information about this error?
Steffen Ullrich pointed out that this error is server-side. This may be useful to others debugging. For us the problem was that we were not sending a client certificate when we were supposed to be.
For now, just a work around - folks on this fourm led me to try
compare openssl ciphers (identical in both my good and bad environments)
openssl s_client -connect news.somewhere.com:563 (worked)
then add the following python code based on output from the above:
import ssl
cntxt = ssl.create_default_context()
cntxt.set_ciphers("AES256-GCM-SHA384")
import nntplib
nntp = nntplib.NNTP_SSL('news.somewhere.com', ssl_context=cntxt)
which solved the SSLV3_ALERT_HANDSHAKE_FAILURE I was getting. (You will want to select the cipher that worked in that s_client test connection to your server.)
There are a dozen library and module version differences between my two environments, but in general the old environment uses python-3.9.7 and the new (broken but now running environment) uses python-3.10.5
Hopefully this narrows things down a bit.

Maximum retries exhausted. Could not install VS Code server on [azure compute instance name]: Cannot communicate with the Jupyter endpoint

I am trying to edit my jupyter notebook which is in Azure ML Workspace. I use the 'edit-in vscode' option, it opens the vs-code or when I try to connect to compute instance directly from vs code, then I am getting the following error:
[Info - 2021-11-08 07:06:06.885] Using commit id "b3318bc0524af3d74034b8bb8a64df0ccf35549a" and quality "stable" for server
[Error - 2021-11-08 07:06:06.971] Invalid response: 405 Method Not Allowed
[Error - 2021-11-08 07:06:06.971] Cannot communicate with the Jupyter endpoint.
[Error - 2021-11-08 07:06:07.981] Maximum retries exhausted. Could not install VS Code server on saksham-dubey: Cannot communicate with the Jupyter endpoint.
Earlier it was working fine and I had no issues with vs-code, I was able to edit/run files directly but without changing anything, it started giving me problem.
So far, I have tried uninstalling/removing vscode completely, reinstall it, deleting Azure compute instance and creating a fresh instance but nothing worked, I am still facing the issue.
What is the problem here and how to resolve this?
ps- saksham-dubey is my compute instance name, which is a Azure Compute Instance (Nvidia Tesla K80 GPU)
Been dealing with the same issue since Friday, tried pretty much anything to no avail.
Luckily I found a workaround by enabling SSH on a new GPU instance & connecting to the instance through Remote SSH from VS Code.
Will keep posted if I found a solution for the UI access.
I found the fix to the problem.
The problem was caused due to some backend error in the 'Azure Machine Learning' vs-code extension.
The issue was caused in the version: 0.6.26
The fix was implemented on the version: 0.6.27
Updating your vs-code extension will make it work.
For any further information you can refer: Github Link to vscode-tools-for-ai
Also you can open an issue on same Github page, if anything like this happens again.

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/plotly/win-64/current_repodata.json>

Good day all,
I tried to install the plotly package on my new work laptop (Windows 10) with the following code:
conda install -c plotly plotly
and I encountered the following error:
Collecting package metadata (current_repodata.json): failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/plotly/win-64/current_repodata.json>
Elapsed: -
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.
'https://conda.anaconda.org/plotly/win-64'
I have tried the following:
Installing the package using my home wifi instead of the company's
Executing conda config --set ssl_verify no
Executing conda config --set ssl_verify false
Copying the 2 files (libcrypto-1_1-x64.dll, libssl-1_1-x64.dll) from Anaconda3\Library\bin to Anaconda3\DLLs.
Interestingly, I was unable to find current_repodata.json file in https://repo.anaconda.com/pkgs/main/win-64/.
Does anyone know how do I create this current_repodata.json file?
Thank you!
I faced similar problems and tried the above options to my dismay.
But somewhere on the internet I had read an answer about using VPN and try different servers and then install using conda.
This seems to work for me now.
Thanks.
Are you in a corporate network behind a proxy?
This issue looks to me like you don't have connection to the internet and your proxy is blocking the connection to https://conda.anaconda.org/plotly/win-64/current_repodata.json
Please try this guide to use conda behind a proxy:
https://docs.anaconda.com/anaconda/user-guide/tasks/proxy/

Running an opencv based python script on a remote server with ssh forwarding from my macbook gives me an error

I am trying to run a python script on a remote server, which includes displaying images. The image does not get displayed and I get an error Gtk-WARNING **: cannot open display:
I have checked posts where they suggest editing the flags in sshd_config and also setting the DISPLAY variable manually. But, none of that seems to be working for me.
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no
XAuthLocation /usr/X11/bin/xauth
Running xclock or xeyes also gives me errors.
Edit: I used ssh -X and ssh -Y to ssh into the server, neither worked
Solution: Restart after installing XQuartz
After looking through multiple posts and trying to make it work, I realised that after installing XQuartz, the user is required to restart the machine. It allows to set the correct environment variables (like DISPLAY). It works for me now after having restarted.
Alternative
However, in case you face a similar problem, not stemming due to the restart issue, I found an alternate way as suggested in the following link:
https://uisapp2.iu.edu/confluence-prd/pages/viewpage.action?pageId=280461906

easy_install/curl fails because of "SSL3_GET_SERVER_CERTIFICATE:certificate verify failed"

I recently installed a new wildcard SHA256 certificate from Comodo. It's a "Premium SSL" cert.
I am now unable to curl/wget, or anything that uses those common SSL libraries, files from the server. I usually get the following message back:
SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
This is particularly an issue when I run easy_install and use our custom cheeseshop as the index, which is using the new cert.
I've tried running sudo update-ca-certificates but that didn't resolve the issue.
My Apache config has the following:
SSLEngine on
SSLCertificateFile /etc/ssl/localcerts/domain.net.crt
SSLCertificateKeyFile /etc/ssl/localcerts/domain.net.key
SSLCertificateChainFile /etc/ssl/localcerts/domain.net.ca-bundle
When I view the site in Chrome or Firefox, I get no errors. I've used online SSL Analysers as well which seem to pass fine.
If I pass the ca-bundle file given to me by Comodo direcly into curl, it works, but otherwise it doesn't.
My understanding is that this is because it's not in /etc/ssl/certs/cacerts.pem. I tried adding the bundled certs in as well, but it didn't work.
What's the best way to resolve this? We're using easy_install with Chef when deploying, so I'd like to avoid having to point to the ca bundle if at all possible.
Thanks.

Categories