I’m trying to run a notebook that I adapted from the JupyterLite folium example in Voici. The repo I am using with GitHub Pages was made yesterday from the current voici-demo repo, using it as a template, and I added a notebook that I had used with Voici before.
I added folium
to the environment.yml
in my current Voici demo test repo here.
When the code execution in the Voici rendering startup gets to import folium
, it fails with TypeError: Can't create an SSLContext object without an ssl module
. You can see the full traceback in response to import folium
by clicking here. (There’s some additional errors from the troubleshooting I have been trying but the traceback associated with the import folium
is the same as it has always been.)
Importantly, the current notebook version works in JupyterLite if I uncomment out %pip install folium
. And import folium
worked in an older voici demo site.
Troubleshooting steps attempted so far:
Based on here and here and here, I thought the problem was that the pyodide doesn’t include ssl
pakage by default, and that I could then run the following in Python and it would load.
import pyodide_js
await pyodide_js.loadPackage("ssl")
And so I added that above the import folium
and it still didn’t work. (After some other steps, I even tried variations on above to try and install ssl with pyodide/micropip, see below for that.)
Then since the error said something about Can't create an SSLContext object
, I thought I’d try adding the following based on here:
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
(I actually meant to just start with the import ssl
line because I thought it would work, but apparently editing the notebook directly by hand, I accidentally appended it to the comment statement, and so I just moved on to trying to add the two lines as a cell.)
But import ssl
gives ModuleNotFoundError: No module named '_ssl'
even though await pyodide.loadPackage("ssl")
was run in the previous cell.
This failure to import ssl is consistent with what folium is saying. But I am missing how I get SSL working in current Voici? Or at least in a way that allows folium to import into Voici without an error. I didn’t see any issues that looked pertinent posted in the folium repo or the Voici one; however, maybe I’m not looking in the correct places.
(I’ll add that I attempted adding openssl
to the environment.yml
based on here, but that curiously caused the Voici rendering to hang on ‘Starting up kernel…’ and so I removed it.).
I also tried micropip.install('ssl')
, and that still didn’t work. import ssl
after that or import folium
fail the same way as I described above.
Same failure for importing ssl and folium with await pyodide.loadPackage('ssl')
placed earlier in the notebook file.
Folium imports into curent JupyterLite and works fine.
And more importantly, a simpler version of this notebook with just import folium
without installing the SSL package via pyodide worked in older versions of Voici. Unfortunately, when I updated the old demo repo I had with some minor changes, the newer build failed to work anymore for even simpler notebook, and kept giving 404 errors. Therefore, I cannot point to an actual demonstration where the folium notebook was working in old Voici, but it just was working well on an older version of the demo the other day.