Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dazzag24 opened this issue Apr 3, 2023 · 3 comments

Comments

@dazzag24
Copy link

dazzag24 commented Apr 3, 2023

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

@koenvo
Copy link
Owner

koenvo commented May 12, 2023

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.

@pierrebrd
Copy link

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

@psymbio
Copy link

psymbio commented Nov 21, 2023

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants