ImportError: Cannot Import Name Cygrpc
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:
- Add
google-cloud-firestore
to yourrequirements.txt
file and install withpip install -U -t lib -r requirements.txt
. - Add these lines to the
libraries
section of yourapp.yaml
file:
libraries:
- name: grpcio
version: 1.0.0
- name: setuptools
version: 36.6.0
- 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:
- Make sure that your installed python version bit(32/64) and your system bit(32/64) are matched.
- If they are not matched please follow the solution mentioned at https://azurelessons.com/cannot-import-name-cygrpc/
Post a Comment for "ImportError: Cannot Import Name Cygrpc"