Read CSV file with Pyscript using Pandas

hey guys i’m using pyscrit with pandas but i get the following message

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’ )

in my web site but the code i wrote in sublime not in using anaconda

so the code’s:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	
	<title>RADAR</title>
	 <link rel="shortcut icon" href="R.jpg" type=image/x-icon>
	<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
<py-env> <!--python library-->
- pandas
 </py-env>

  <py-script> 
import pandas as pd
df=pd.read_csv('cmaregraphe.csv', sep='[;\s]+', engine='python')
p=df['Niveau'].max()
print(p)
 </py-script>  
</body></html>

my csv file contains

any help please :pray:t2: :pray:t2:

1 Like

dear lahsaouinouhaila.

Thank you for posting.

Since you presented the detailed error code and source code, it was easy to understand the cause.
For details, please refer to the following URL, but it can be easily corrected.

pyscript

Regards, you.
ktsh.tanaka.2020

hello sir @ktsh.tanaka.2020 i would tell you that i can use python normaly (what i tested yesterday’s :point_right:t2:print(‘hello’) i can see the result in my web site normaly without appering any error message also i tried this code

  <py-script> 
 from datetime import datetime
 now = datetime.now()
 now.strftime("%d/%m/%Y, %H:%M:%S")
 </py-script>  

it’s working perfectly but why pandas it’s not working that’s what i want to know i saw some videos on youtube talking about pandas and using pyscript but no one get the same error message i has i hope i can find a solution cause i really need to connect my python script to my browzer

1 Like

dear lahsaouinouhaila.

thank you for reply.

In pyscript, Pandas often doesn’t work because the numpy, pytz, and dateutil needed to run Pandas are often not imported.

I think this is because the current pyscript specification requires you to specify the required packages directly.

In other words, libraries that are located directly in the /lib/python3.9 directory instead of site-packages will be imported without doing anything, but in the case of other libraries, if they are not directly located. I don’t think it has been imported.

Especially in the case of numpy and scipy, not only python scripts but also libraries such as dll and lib.so are used.

In other words, pyscript is not a runtime engine, but an interface for launching Python on the base system.

If you have any requests for improvement in the future, we would appreciate it if you could contact us.

Regards, you.
ktsh.tanaka.2020

1 Like

Thank you sir for replying I appreciate it .
I wonder if I can use some thing else that can play the same role as pandas using pyscript

1 Like

dear lahsaouinouhaila.

thank you for reply.
I have a few options, each with its pros and cons.

For details, please refer to the article at the following URL.

In terms of using numpy, GPU, SQL, etc., they may not be compatible with Pyscript.

ktsh.tanaka.2020

1 Like