Python
Published

March 21, 2024

Requests in JupyterLite

In a recent post, I tried to use requests in JupyterLite. It did not work at the time.

Today, I have found out that urllib3 recently announced support for Pyodide, the Python distribution used by JupyterLite.

Now, you can use requests or urllib3 in JupyterLite and this code does also work in the browser environment (install packages with micropip).

# import micropip
# await micropip.install("requests")

import urllib3
urllib3.disable_warnings()

import requests

headers = {"accept": "text/x-bibliography"}
r = requests.get("https://doi.org/10.5281/zenodo.7043510", headers=headers)

r.text
'Döring, H., &amp; Herrmann, M. (2024). <i>Party positions from Wikipedia tags</i> (Version 24.07) [Computer software]. Zenodo. https://doi.org/10.5281/ZENODO.7043510'