pyodide-http icon indicating copy to clipboard operation
pyodide-http copied to clipboard

SSLError("Can't connect to HTTPS URL because the SSL module is not available.")

Open dazzag24 opened this issue 2 years ago • 3 comments

Using the pyscript example in the tests folder.

Server up the file using python -m http.server --directory dist 8081

Visit page using Firefox results in the following error in browser console:

APPENDING: True ==> py-8457af36-6e5c-d18f-55ca-9cc14c4d72d4 --> PythonError: Traceback (most recent call last):
  File "/lib/python3.10/site-packages/urllib3/connectionpool.py", line 692, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "/lib/python3.10/site-packages/urllib3/connectionpool.py", line 281, in _get_conn
    return conn or self._new_conn()
  File "/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1011, in _new_conn
    raise SSLError(
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 "/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /pyodide/pyodide/main/docs/_static/img/pyodide-logo-readme.png (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 "/lib/python3.10/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/lib/python3.10/asyncio/tasks.py", line 232, in __step
    result = coro.send(None)
  File "<exec>", line 12, in init
  File "/lib/python3.10/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/lib/python3.10/site-packages/requests/adapters.py", line 563, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /pyodide/pyodide/main/docs/_static/img/pyodide-logo-readme.png (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

Any ideas?

Thanks

Darren

dazzag24 avatar Apr 03 '23 10:04 dazzag24

I kind of missed this issue.

Are you sure you did the patch_all? It seems it's using the regular requests instead of a patched one.

koenvo avatar May 12 '23 17:05 koenvo

I have a similar problem, have you found a solution ?

pierrebrd avatar Aug 03 '23 12:08 pierrebrd

Installing ssl and importing before the pyodide patch fixes this for me:

await micropip.install("ssl")
import ssl

import pyodide_http
pyodide_http.patch_all()

psymbio avatar Nov 21 '23 06:11 psymbio