Problem with Pyscript libary installation

34 Views Asked by At

enter image description here

I added the needed google-generativeai but it still dosent work. Can someone help?

Here is the parts of thePy script enter image description here

Normaly the script should look like this enter image description here

1

There are 1 best solutions below

0
Jeff Glass On

From your error message, I suspect you're using an older version of PyScript. A complete example using the most recent release as of today (2024.1.3) is:

<link rel="stylesheet" href="https://pyscript.net/releases/2024.1.3/core.css">
<script type="module" src="https://pyscript.net/releases/2024.1.3/core.js"></script>
<py-config>
  packages=['google-generativeai']
</py-config>
<script type="py">
  from pyscript import display
  import google.generativeai as genai
  display(dir(genai))  
</script>

This solves the import error, but runs into a later Module Not Found issue, since gRPC is not implemented in the Browser. See this discussion on the Pyodide repo.