Import pandas - No module named 'pandas'

Hi,

It is my first time using trying to import pandas.

I’m getting the following error:

JsException(PythonError: Traceback (most recent call last): File “/lib/python3.10/site-packages/_pyodide/_base.py”, line 429, in eval_code .run(globals, locals) File “/lib/python3.10/site-packages/_pyodide/_base.py”, line 300, in run coroutine = eval(self.code, globals, locals) File “”, line 1, in ModuleNotFoundError: No module named ‘pandas’ )

and this is my html script:

<html>
	<head>
		<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
		<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
	<py-env>
		- pandas
	</py-env>
	</head>
	<body>
    <py-script> 
import pandas as pd
	</py-script>
	</body>
</html>

Any explanation to why I’m receiving such error?

Regards,

What happens if you try running the folium example?

Dear Neil,

Thank you so much for the help you provided.
It is working now.
However, I’m facing an issue, which is that pandas not reading from my PC.

I executed the below lines:

import os

cwd = os.getcwd()
files = os.listdir(cwd) 
print("Files in %r: %s" % (cwd, files))

This is the output:

Files in ‘/home/pyodide’:

Which is not my PC.

Regards,

/home/pyodide is the browser virtual file system. Applications (Python/JavaScript) running inside the browser cannot directly access a user’s local file system. Doing so would be a serious security problem. You must request file access using one of the browser APIs such as FileReader() or showOpenFilePicker(). These articles will help you:

2 Likes