From js import fetch - error

I am trying to run the getting started example and the command
from js import fetch
and I get the error
ModuleNotFoundError: No module named ‘js’

What do I need to do to have the module?


I have the same issue.
-Using: Anaconda for windows 2021.11
-link to example page: Anaconda Nucleus
Looking forward to reply.

Tried workaround:
Imported the whole js module and referenced the fetch function within js

import js
res = await js.fetch(‘’)

Highlights an issue in the editor
“Cannot find reference ‘fetch’ in ‘’”

Ran it anyway…
res = await js.fetch(‘’)
SyntaxError: ‘await’ outside function

The Nucleus example runs on a completely different version of python - one that is compiled for use within Node.js. This specific python compilation includes the js module. Therefore, you cannot import this from ‘normal’ python.

See here: Pyodide — Version 0.19.0


Not a great getting started example if we can not replicate it on our machines. Does anyone have any direction on how to get this example to work on our machines?

For those looking to run this in their own installation of Jupyter. It is easy to remove the reference to from js import fetch being reliant on python with javascript built-in. Simply delete or skip the second cell with the reference to js and the fetch from the URL, then in the third cell change it to:

df = pd.read_csv(‘’)

Let pandas read_csv function read directly from the url to get the csv data and then load it into a data frame. No need to even use fetch from javascript as Pandas can handle this all on it’s own. If I am not clear and you are still having issues drop me a message, glad to help out.

Hi! Not sure if I understood well what you mean. I just tried:

df = pd.read_csv(' 7')

but it seems that the URL is not valid. I get some error messages ending with:

df = pd.read_csv(' 7')

Here is snippet, if that helps you.

#import js <=== Comment this line
#from js import fetch <== Comment this line
import io

URL = ‘df = pd.read_csv(‘ 7’)
#resp = await fetch(URL) <== Comment this line
#text = io.BytesIO((await resp.arrayBuffer()).to_py()) <== Comment this line

df = pd.read_excel(
sheet_name=‘Your sheet name’,
print(‘Data downloaded and read into a dataframe!’)

df = pd.read_csv(“”)