-1

First thing first, i'm somewhat extremely new to python and jupyter and ohter stuff. So i'm enrolling in this Python for data science class from cognitiveclass.ai . currently at Module 4 - Working with Data in Python and theres this lab exercise where it imported pyfetch and it works just fine no error. then i try it in my jupyter notebook and
ModuleNotFoundError: No module named 'pyodide' ...

as any other person here i google this problem and i found that if a module not found, we could just go to the terminal and download the module name with pip or pip3. and here i'm not sure if i have import/download pyfetch or pyodide itself supposed to be a package provided virtually or something like that. so that it i guess.

please ask me more cause i'm also not entirely sure what else i should clarify about this problem.

megamayo
  • 7
  • 1

2 Answers2

2

Pyodide is loaded from a JavaScript file. It is loaded in the HTML <head> tag.

<!DOCTYPE html>
<html>
  <head>
    <script src="https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js"></script>
  </head>
  <body>
  <div id="msg">Loading page ...</div>
  <br>
    <script type="text/javascript">
        async function main() {
                let pyodide = await loadPyodide();
                // Add more code
        }

      main();
    </script>
  </body>
</html>
John Hanley
  • 74,467
  • 6
  • 95
  • 159
2

It's very likely that your notebook is running Python in the browser with WebAssembly using the Pyodide project.

pyfetch function is part of the Pyodide core package, and indeed you cannot currently install it outside of the browser with pip. This is a bug, and we will address it in https://github.com/pyodide/pyodide/issues/1839 after with you will be able to install it with,

pip install pyodide-core-py

Meanwhile, you can run your notebook in other notebook environments that uses Pyodide such as JupyterLite.

So overall it's a valid usability issue and something that needs improving.

rth
  • 10,680
  • 7
  • 53
  • 77