!wget or urllib.request in JupyterLite (browser)

Hello, I am facing a problem when using JupyterLite (the Browser python environment JupyterLite) when trying to download a file on the web. I tried to use both !wget urltofile (or os.system(‘wget urltofile’)) or urllib.request but without success. It seems the browser version do not allow for external connections.
For instance

!wget https://raw.githubusercontent.com/jorishey1234/glyapp/refs/heads/main/gly_toolbox.py 

raise the error : “raise OSError(“Background processes not supported.”)”

And

import urllib
url = 'https://raw.githubusercontent.com/jorishey1234/glyapp/refs/heads/main/'
filename = 'gly_toolbox.py'
urllib.request.urlretrieve(url, filename)

raise the error “URLError: <urlopen error [Errno 23] Host is unreachable>”

An idea to circumvent the problem ?

Thanks a lot,

Joris

There is some documentation about fetching remote content after using the pyodide_http monkeypatches.

The ! line magic is generally not going to work in that environment, nor will the % line and %% cell magics that shell out and haven’t been even partially re-implemented, e.g. %pip.

2 Likes