“No module named cloud” when deploying to Google App Engine
I’ve built an app for Google App Engine and when I try to run the app, it works fine. But when I deploy it, it throws an internal server 500 error. When I check the error report, it says, “There is no module named cloud in the directory”
Here is my requirements .txt
gunicorn==19.3.0
twilio==6.8.4
google-cloud-automl==0.1.1
google-cloud-storage==1.0.0
google-cloud==0.34.0
GoogleAppEngineCloudStorageClient==1.9.22.1
My yaml file is as follows
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: .*
script: main.app
The import used in the python file is
:
from google.cloud import automl_v1beta1 as automl
from google.cloud import storage
When I ran it manually it worked. However, an error is reported after deployment
ImportError: No module named cloud
<module> (/base/data/home/apps/..
Thanks in advance
Solution
It looks like you’re trying to deploy to the “first generation” App Engine runtime. Unfortunately, you can’t use the google-cloud
Python library there.
The good news is that you can switch to “second generation,” which allows you to install any library, including any google-cloud library, such as google-cloud-storage
.
Check out this link to learn about the differences between the two generations: https://cloud.google.com/appengine/docs/standard/appengine-generation
Google App Engine Python 3 standard environment documentation: https://cloud.google.com/appengine/docs/standard/python3/