How to use Datastore in pyscript?

I’m trying to import, but I get several errors, depending on how I import.
Importing from other libraries like matplot, numpy… works.

    <py-env>
      - matplotlib
      - google-cloud-datastore
    </py-env>
    </head>
  <body>
    <div id="mpl"></div>
    <py-script output="mpl">
import matplotlib.pyplot as plt
from google.cloud import datastore
<!-- import google-cloud-datastore -->
import matplotlib.tri as tri
import numpy as np

It sounds like your issue is similar to Pyodide Issue #1611, in that google-cloud-datastore assumes setuptools is always installed, but this isn’t necessarily tool. Adding setuptools to your <py-env> tag fixes that issue…

But at least for me, the next error is about not finding the grpc module; from the gRPC quickstart guide, that’s on PyPI as grpcio, but unfortunately that’s a largely C and C++ based package.

Pyodide can only load pure-python wheels from PyPI, or packages already built in Pyodide, or out-of-tree builds using Emscripten. You might be able to build grpc with Emscripten, but other than that, this may not be possible to use in PyScript currently.

2 Likes