Skip to content

Python 3.7.3 from Anaconda3 cannot make https request or import ssl #19

@misue123

Description

@misue123

I am running a python script using python 3.7.3 from Anaconda 3 installed a week ago. It could not make https request to a simple website like https://www.bing.com with the following error. The python is called from cgi in IIS web server.

Traceback (most recent call last):
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\urllib3\connectionpool.py", line 588, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\urllib3\connectionpool.py", line 248, in _get_conn
return conn or self._new_conn()
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\urllib3\connectionpool.py", line 816, in _new_conn
raise SSLError("Can't connect to HTTPS URL because the SSL "
urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\urllib3\util\retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.bing.com', port=443): Max retries exceeded with url: / (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\inetpub\wwwroot\demo\myForm.py", line 177, in
response = requests.get("https://www.bing.com/")
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\ProgramData\Anaconda3_x64\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.bing.com', port=443): Max retries exceeded with url: / (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

To troubleshoot, I added "import ssl" in the code, it threw an error as below. However, in conda prompt, there was no error with import ssl, and it points to the same ssl.py.

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. I tried this with 32bit and 64 bits Anaconda installation and had the same problem.

C:\inetpub\wwwroot\demo\myForm.py in ()
82 import sys

 83 #import dateutil

=> 84 import ssl

 85 

 86 #---------

ssl undefined
C:\ProgramData\Anaconda3_x64\lib\ssl.py in ()
96 from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag

 97 

=> 98 import _ssl # if we can't import it, let the error propagate

 99 

100 from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION

_ssl undefined

ImportError: DLL load failed: The specified module could not be found.
args = ('DLL load failed: The specified module could not be found.',)
msg = 'DLL load failed: The specified module could not be found.'
name = '_ssl'
path = r'C:\ProgramData\Anaconda3_x64\DLLs_ssl.pyd'
with_traceback =

Note that I also had to update numpy to make the import work for 64bits version, but updating openssl to 1.1.1b did not help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions