No module named google.appengine.api module with the python runtime

6,711 views
Skip to first unread message

mubarak basuudde

unread,
Nov 4, 2017, 4:51:16 PM11/4/17
to Google App Engine
So using the python runtime :

Installed google sdk 
installed app-engine-python
 so moving to my app virtualenv 

with the following requirements.txt
google-cloud-storage==1.6.0
googleapis-common-protos==1.3.5
google-api-python-client


in the app script i have 
from google.appengine.api import images

but when i run the script it continuously throw a ImportError:
No module named google.appengine.api 

And of-course looking at the lib/google
there is no such module folder appengine

Given i followed all installation steps i left wondering were there changes made but never communicated.

Kenworth (Google Cloud Platform)

unread,
Nov 5, 2017, 1:53:16 PM11/5/17
to Google App Engine
You need first to install gcloud python module & google-api-python-client module with:

pip install --upgrade gcloud
pip install --upgrade google-api-python-client

If you are still affected after the above suggested troubleshooting steps, please provide redacted full error logs and a link to the steps you followed to arrive at this issue.

Randall Toepfer

unread,
Feb 18, 2018, 12:13:21 PM2/18/18
to Google App Engine
I am on Ubuntu.  I installed glcoud SDK according to the docs and installed the appengine python components from command line.  I ran the commands below and ran pip install globally and to my virtual environment.   I also tried updating my PYTHONPATH env variable in bashrc.  Only after I explicitly udpated sys.path in Django did the import work, but not successfullly as I still get a YAML not found error.

Here's my bash:
PYTHONPATH=$PYTHONPATH:/home/randall/Downloads/google-cloud-sdk/platform/google_appengine:/home/randall/Downloads/google-cloud-sdk/platform/google_appengine/lib/:/home/randall/Downloads/google-cloud-sdk/platform/google_appengine/lib/yaml/

randall@randall-VirtualBox3:~$ cd triton/triton

randall@randall
-VirtualBox3:~/triton/triton$ source env/bin/activate

(env) randall@randall-VirtualBox3:~/triton/triton$ python manage.py runserver

/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/db/models/base.py:325: RuntimeWarning: Model 'main.jobfile' was already registered. Reloading models is not advised as it can lead to inconsistencies, most notably with related models.

  new_class
._meta.apps.register_model(new_class._meta.app_label, new_class)

/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/db/models/base.py:325: RuntimeWarning: Model 'main.jobfile' was already registered. Reloading models is not advised as it can lead to inconsistencies, most notably with related models.

  new_class
._meta.apps.register_model(new_class._meta.app_label, new_class)

Performing system checks...



Unhandled exception in thread started by <function wrapper at 0x7efcdd5b5410>

Traceback (most recent call last):

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper

    fn
(*args, **kwargs)

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run

   
self.check(display_num_errors=True)

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check

    include_deployment_checks
=include_deployment_checks,

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks

   
return checks.run_checks(**kwargs)

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks

    new_errors
= check(app_configs=app_configs)

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config

   
return check_resolver(resolver)

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver

   
return check_method()

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 254, in check

   
for pattern in self.url_patterns:

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__

    res
= instance.__dict__[self.name] = self.func(instance)

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 405, in url_patterns

    patterns
= getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__

    res
= instance.__dict__[self.name] = self.func(instance)

 
File "/home/randall/triton/triton/env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 398, in urlconf_module

   
return import_module(self.urlconf_name)

 
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module

    __import__
(name)

 
File "/home/randall/triton/triton/triton/urls.py", line 4, in <module>

   
from main.views import *

 
File "/home/randall/triton/triton/main/views.py", line 22, in <module>

   
import cloudstorage as gcs                                                                                                                                                                                                                                                  
 
File "/home/randall/triton/triton/triton/../lib/cloudstorage/__init__.py", line 20, in <module>                                                                                                                                                                              
   
from .api_utils import RetryParams                                                                                                                                                                                                                                          
 
File "/home/randall/triton/triton/triton/../lib/cloudstorage/api_utils.py", line 51, in <module>                                                                                                                                                                              
   
from google.appengine.ext import ndb                                                                                                                                                                                                                                        
 
File "/home/randall/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/ext/ndb/__init__.py", line 22, in <module>                                                                                                                                          
   
from tasklets import *                                                                                                                                                                                                                                                      
 
File "/home/randall/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/ext/ndb/tasklets.py", line 85, in <module>                                                                                                                                          
   
from .google_imports import apiproxy_stub_map                                                                                                                                                                                                                              
 
File "/home/randall/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/ext/ndb/google_imports.py", line 67, in <module>                                                                                                                                    
   
from google.appengine.api.blobstore import blobstore as api_blobstore                                                                                                                                                                                                      
 
File "/home/randall/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/api/blobstore/__init__.py", line 23, in <module>                                                                                                                                    
   
from blobstore import *                                                                                                                                                                                                                                                    
 
File "/home/randall/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/api/blobstore/blobstore.py", line 39, in <module>                                                                                                                                  
   
from google.appengine.api import datastore                                                                                                                                                                                                                                  
 
File "/home/randall/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/api/datastore.py", line 63, in <module>                                                                                                                                            
   
from google.appengine.datastore import datastore_query                                                                                                                                                                                                                      
 
File "/home/randall/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/datastore/datastore_query.py", line 65, in <module>                                                                                                                                
   
from google.appengine.datastore import datastore_index                                                                                                                                                                                                                      
 
File "/home/randall/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/datastore/datastore_index.py", line 61, in <module>                                                                                                                                
   
import yaml                                                                                                                                                                                                                                                                
ImportError: No module named yaml


Here's output of gcloud info:

(env) randall@randall-VirtualBox3:~/triton/triton$ gcloud info

Google Cloud SDK [188.0.1]



Platform: [Linux, x86_64] ('Linux', 'randall-VirtualBox3', '4.8.0-59-generic', '#64-Ubuntu SMP Thu Jun 29 19:38:34 UTC 2017', 'x86_64', 'x86_64')

Python Version: [2.7.12+ (default, Sep 17 2016, 12:08:02)  [GCC 6.2.0 20160914]]

Python Location: [/home/randall/triton/triton/env/bin/python2]

Site Packages: [Enabled]



Installation Root: [/home/randall/Downloads/google-cloud-sdk]

Installed Components:

  core
: [2018.02.08]

  app
-engine-python: [1.9.66]

  gcloud
: []

  app
-engine-python-extras: [1.9.63]

  beta
: [2017.09.15]

  gsutil
: [4.28]

  bq
: [2.0.28]

System PATH: [/home/randall/triton/triton/env/bin:/home/randall/Downloads/google-cloud-sdk/bin:/home/randall/bin:/home/randall/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/bin:/home/randall/nviro
leaks
.com/spark-installer]

Python PATH: [/home/randall/Downloads/google-cloud-sdk/lib/third_party:/home/randall/Downloads/google-cloud-sdk/lib:/home/randall/triton/triton/env/lib/python2.7:/home/randall/triton/triton/env/lib/python2.7/plat-x86_64-linux-gnu:/home/randall/triton/triton/env/lib/pytho
n2
.7/lib-tk:/home/randall/triton/triton/env/lib/python2.7/lib-old:/home/randall/triton/triton/env/lib/python2.7/lib-dynload:/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/home/randall/triton/triton/env/local/lib/python2.7/site-pack
ages
:/home/randall/triton/triton/env/lib/python2.7/site-packages]

Cloud SDK on PATH: [True]

Kubectl on PATH: [False]



Installation Properties: [/home/randall/Downloads/google-cloud-sdk/properties]

User Config Directory: [/home/randall/.config/gcloud]

Active Configuration Name: [default]

Active Configuration Path: [/home/randall/.config/gcloud/configurations/config_default]



Account: [randall.toepfer@gmail.com]

Project: [triton-179021]



Current Properties:

 
[core]

    project
: [triton-179021]

    account
: [randall.toepfer@gmail.com]

    disable_usage_reporting
: [False]



Logs Directory: [/home/randall/.config/gcloud/logs]

Last Log File: [/home/randall/.config/gcloud/logs/2018.02.17/19.59.50.857801.log]



git
: [git version 2.9.3]

ssh
: [OpenSSH_7.3p1 Ubuntu-1ubuntu0.1, OpenSSL 1.0.2g  1 Mar 2016]





(env) randall@randall-VirtualBox3:~/triton/triton$

This is my code:

views.py

import cloudstorage as gcs
from google.appengine.api import app_identity


What's missing?
Reply all
Reply to author
Forward
0 new messages