getting-started-python: Import error on deploy only: No module named google.appengine.api

I’ve been following the tutorial, in particular section 6-pubsub. I have the project working locally just fine, but when I try to deploy, I get a timeout. See the stacktrace from the logs below. The import error is:

ImportError: No module named 'google.appengine.api'

and it occurs when I try to make a new logging Client. I’ve seen the same issue in another project when I try to make a new pubsub Client.

2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |   File "/home/vmagent/app/main.py", line 19, in <module>
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |     app = bookshelf.create_app(config)
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |   File "/home/vmagent/app/bookshelf/__init__.py", line 40, in create_app
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |     client = google.cloud.logging.Client(app.config['PROJECT_ID'])
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |   File "/env/lib/python3.4/site-packages/google/cloud/client.py", line 186, in __init__
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |     Client.__init__(self, credentials=credentials, http=http)
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |   File "/env/lib/python3.4/site-packages/google/cloud/client.py", line 122, in __init__
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |     credentials = get_credentials()
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |   File "/env/lib/python3.4/site-packages/google/cloud/credentials.py", line 87, in get_credentials
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |     return client.GoogleCredentials.get_application_default()
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |   File "/env/lib/python3.4/site-packages/oauth2client/client.py", line 1288, in get_application_default
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |     return GoogleCredentials._get_implicit_credentials()
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |   File "/env/lib/python3.4/site-packages/oauth2client/client.py", line 1273, in _get_implicit_credentials
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |     credentials = checker()
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |   File "/env/lib/python3.4/site-packages/oauth2client/client.py", line 1191, in _implicit_credentials_from_gae
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |     return _get_application_default_credential_GAE()
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |   File "/env/lib/python3.4/site-packages/oauth2client/client.py", line 1450, in _get_application_default_credential_GAE
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |     from oauth2client.contrib.appengine import AppAssertionCredentials
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |   File "/env/lib/python3.4/site-packages/oauth2client/contrib/appengine.py", line 27, in <module>
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  |     from google.appengine.api import app_identity
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 worker.1  | ImportError: No module named 'google.appengine.api'
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 system    | worker.1 stopped (rc=1)
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 system    | sending SIGTERM to monitor.1 (pid 8)
2016-11-02 17:02:18 worker[20161102t123058]  17:02:18 system    | monitor.1 stopped (rc=-15)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 25

Most upvoted comments

Thank you. I’m trying to reproduce. This error is extremely bewildering.

@theacodes

please help me, i have same issue No module named ‘google.appengine’

my requirements.txt

Django==2.1.10
PyMySQL==0.9.3
numpy==1.17.0
plotly==4.0.0
pandas==0.25.0
requests==2.22.0

Flask==0.11.1
google-cloud==0.19.0
gunicorn==19.6.0
oauth2client==3.0.0
Flask-SQLAlchemy==2.1
Flask-PyMongo==0.4.1
PyMongo==3.3.0
six==1.10.0
honcho==0.7.1
psq==0.5.0
googleapis-common-protos==1.3.5

app.yam

# [START django_app]
runtime: python37

runtime_config:
  python_version: 3

handlers:
# This configures Google App Engine to serve the files in the app's static
# directory.
- url: /static
  static_dir: static/

# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
  script: auto
# [END django_app]

thank you

Hi, I’ve got the same thing than @MohammadHeydari, and for the error its’: “No module named ‘oauth2client.locked_file’” and “No module named ‘google.appengine’”

@aheyman11 good to hear. FYI, a new release of googleapis-common-protos has been released so it should be safe to remove that from your requirements.txt

Thank you so much for answering all of my questions and helping me figure out this rather surprising bug. 😃

@aheyman11 thanks, I’ve tracked this down.

You should be able to add this to your requirements.txt and things (hopefully) should work:

googleapis-common-protos==1.3.5