Skip to content Skip to sidebar Skip to footer

ImportError: Cannot Import Name Cygrpc

I am trying to use Firebase Native mode on Google App Engine - Standard. My python language is Python 2.7. When I try to from google.cloud import firestore, I get an error ImportEr

Solution 1:

A while ago GRPC wasn't supported on GAE standard, see GRPC and types import error in App Engine Datastore. I didn't try since, but I don't see newer activity on issue 149.

Also the cython reference in the traceback suggests that it may include compiled code, which would violate the pure python standard environment sandbox restrictions that applies to the code you deploy.


Solution 2:

It's 2020, and you can now use grpcio (without explicitly adding it yourself as it's a built-in library) w/Cloud Firestore natively on App Engine with Python 2.7. Three things to make this work:

  1. Add google-cloud-firestore to your requirements.txt file and install with pip install -U -t lib -r requirements.txt.
  2. Add these lines to the libraries section of your app.yaml file:
libraries:
- name: grpcio
  version: 1.0.0
- name: setuptools
  version: 36.6.0
  1. Ensure these lines are in your appengine_config.py file:
import pkg_resources
from google.appengine.ext import vendor

# Set path to your libraries folder.
path = 'lib'
# Add libraries installed in the path folder.
vendor.add(path)
# Add libraries to pkg_resources working set to find the distribution.
pkg_resources.working_set.add_entry(path)

Of course, we do recommend you eventually migrate to Python 3 to take advantage of the greater flexibility the next generations (of Python and App Engine) provide, esp. the ability to tap into other GCP services. However, caveat such a port isn't without effort if your app is complex & deeply-dependent on App Engine's 1st gen built-in services. Most of the suggestions above are derived from this section of the migration docs.


Solution 3:


Post a Comment for "ImportError: Cannot Import Name Cygrpc"