Context
I am working behind a corporate proxy with a self-signed certificate. I have documented this extensively.
- https://stackoverflow.com/a/52961564/622276
- https://stackoverflow.com/a/41253757/622276
The issue now is that TLS/SSL module is not loading correctly to even verify the certificates.
- Windows 10
- Anaconda 2018.12 (Python 3.7.1)
- git version 2.19.0.windows.1
Question
python -c "import ssl"
I can get it to work in Anaconda Prompt, but not in Git Bash. Why is there a difference?
Steps
Using Git Bash
I started with the basic install of the latest (at time of writing) Anaconda distribution 2018.12 and tried to install redis
.
$ pip install redis
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting redis
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/redis/
...
Could not fetch URL https://pypi.org/simple/redis/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/redis/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Could not find a version that satisfies the requirement redis (from versions: )
No matching distribution found for redis
So that is weird. SSLError("Can't connect to HTTPS URL because the SSL module is not available.")
. So I tried just importing ssl
.
$ python -c "import ssl"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified procedure could not be found.
Anaconda Prompt
(base) C:\Users\username> python -c "import ssl"
(base) C:\Users\username>
No errors. Just a blank line.
(base) C:\Users\username> conda deactivate
C:\Users\username>
C:\Users\username> python -c "import ssl"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified procedure could not be found.
After deactivating the base conda environment I can replicate the error in an Anaconda Prompt.
Summary
So obviously the _ssl.pyd
file in C:\Users\username\AppData\Local\Continuum\anaconda3\DLLs
does work but there is something I'm missing or do not know how to debug further to figure out why it does not work in Git Bash.
I do not understand how to debug how python loads DLLs and how Anaconda environments influences this.