1

I am building a RESTful API using Python 3.6, the Falcon Framework, Google App Engine, and Firebase Cloud Firestore. At runtime I am receiving the following error ...

File "E:\Bill\Documents\GitHubProjects\LetsHang-BackEnd\lib\google\cloud\firestore_v1beta1\_helpers.py", line 24, in <module> import grpc
File "E:\Bill\Documents\GitHubProjects\LetsHang-BackEnd\lib\grpc\__init__.py", line 22, in <module>
 from grpc._cython import cygrpc as _cygrpc
ImportError: cannot import name cygrpc

When researching StackOverFlow, I found an article regarding an AWS Lambda deployment, but it suggests a solution based on Docker. Docker is not a viable solution for us. I also found an article off StackOverflow that suggests running "pip install grpcio". We did not without luck.

We build the App Engine dependencies using a requirements.txt file. This file has the following contents ...

falcon==1.4.1
google-api-python-client
google-cloud-firestore
firebase-admin
enum34
grpcio

We apply the requirements file using the command ...

pip install -t lib -r requirements.txt

The App Engine server is started with the command ...

dev_appserver.py .

The development environment is Windows 10.

Bill McCann
  • 23
  • 1
  • 4

2 Answers2

2

You seem to be mixing up the GAE standard and flexible environments:

  • using Python 3.6 is only possible in the flexible environment (which, BTW, is fundamentally Docker-based)
  • installing app dependencies in the lib directory and using dev_appserver.py for local development are only applicable to the standard environment

Somehow related: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
1

Ok. I will write up my findings just in case there's another fool like me.

First, Dan's response is correct. I was mixing standard and flexible environments. I had looked up a method for using the Falcon Framework with App Engine; as it turns out, the only article uses the standard environment. So that's how I wound up using dev_appserver.py. My app, however, is Python 3.6 and has dependencies that prevent stepping down to 2.7.

To develop locally for the flexible environment, you simply need to run as you normally would. In the case of Falcon Framework, that means using the Waitress wsgi server.

I find that it is a good practice to build and use a Python virtual environment. You use the virtualenv command for that. At deployment time, Google builds a docker container for the app in the cloud. To reconstruct all the necessary Python packages, you have to supply a requirements.txt file. If you have a virtual environment, then the requirements file is easily produced using pip freeze.

Bill McCann
  • 23
  • 1
  • 4