When running the FlightRadarAPI on python 3.12, windows 11 I'm getting an ImportError: Can't connect to HTTPS URL because the SSL module is not available.
Traceback (most recent call last):
File "/lib/python311.zip/_pyodide/_base.py", line 499, in eval_code
.run(globals, locals)
^^^^^^^^^^^^^^^^^^^^
File "/lib/python311.zip/_pyodide/_base.py", line 340, in run
coroutine = eval(self.code, globals, locals)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<exec>", line 55, in <module>
File "/lib/python3.11/site-packages/FlightRadar24/api.py", line 309, in get_flights
response = APIRequest(Core.real_time_flight_tracker_data_url, request_params, Core.json_headers)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.11/site-packages/FlightRadar24/request.py", line 56, in __init__
self.__response = request_method(url, headers = headers, cookies = cookies, data = data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.11/site-packages/requests/api.py", line 73, in get
return request("get", url, params=params, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.11/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/lib/python3.11/site-packages/urllib3/connectionpool.py", line 769, in urlopen
conn = self._get_conn(timeout=pool_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.11/site-packages/urllib3/connectionpool.py", line 295, in _get_conn
return conn or self._new_conn()
^^^^^^^^^^^^^^^^
File "/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1060, in _new_conn
raise ImportError(
ImportError: Can't connect to HTTPS URL because the SSL module is not available.
To add to the complexity, the code works when run normally, the error only happens while running it via PyScript (a combination of python and html)
The SSL module is unvendored by default in Pyodide, but can be installed in PyScript using:
<py-config>
packages=['ssl']
</py-config>
Once you install it, however, note that SSL generally doesn't function in browser, since socket is not available in the browser. See also this GitHub Issue for more discussion.