AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials' with App Engine + Earth Engine API python

1,525 views
Skip to first unread message

Michael Johansson

unread,
Sep 21, 2016, 9:18:11 AM9/21/16
to Google App Engine
So I'm trying to learn App engine and the earth engine api.
I'm pretty new to this.
I am therefore trying to get some tutorial demos to work. More specifically the "trendy lights" demo found here.
I am on windows 7, running python 2.7.11 and I followed steps in this short guide.

If this is not the right forum to ask in, please do wave me in the right direction!

What I'm doing is:
Because I'm on windows, I can't run "build.sh" so I'm building the "lib" folder manually, adding/installing
   'pip install -t lib earthengine-api'
   'pip install -t lib pycrypto'
   'pip install -t lib oauth2client'

When my "Tredny Lights" app folder and files are completed I run it through App engine launcher.
I have also tried via the command line argument dev_appserver.py, but I get the same error.
I have not changed any files that comes with the demo except for the application name in app.yaml and the authentication in config.py

The error I get is:
AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials'
A browser window opens but it is just blank white.

What am I missing, is it something obvious?
I don't really know where to go from here so any suggestions would be greatly appreciated.


This is the full error message:
 
 File "C:\Program Files (x86)\Google\google_appengine\

google\appengine\runtime\wsgi.py"
, line 240, in Handle
    handler
= _config_handle.add_wsgi_middleware(self._LoadHandler())
 
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 299, in _LoadHandler
    handler
, path, err = LoadObject(self._handler)
 
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 85, in LoadObject
    obj
= __import__(path[0])
 
File "C:\Users\Majkiboy\local-repo-trndy-lights\trendy-lights\server.py", line 226, in <module>
    config
.EE_ACCOUNT, config.EE_PRIVATE_KEY_FILE)

 
File "C:\Users\Majkiboy\local-repo-trndy-lights\trendy-lights\lib\ee\_helpers.py", line 60, in ServiceAccountCredentials
   
return oauth2client.client.SignedJwtAssertionCredentials(
AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials'

INFO    
2016-09-20 14:50:51,029 module.py:788] default: "GET / HTTP/1.1" 500 -Enter code here...




My appengine_config.py file:

from google.appengine.ext import vendor
vendor
.add("lib")


My app.yaml file:

application: trendy-lights
version
: 1

runtime
: python27
api_version
: 1
threadsafe
: true

libraries
:
- name: jinja2
  version
: "2.6"
- name: webapp2
  version
: "2.5.1"
- name: pycrypto
  version
: "2.6"

handlers
:
- url: /static/
  static_dir
: static
  application_readable
: true
  secure
: always
- url: /.*
  script: server.app
  secure: always

skip_files:
- ^(.*/
)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*\.py[co]$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\..*$
- Crypto


//Michael

Michael Johansson

unread,
Sep 21, 2016, 10:05:44 AM9/21/16
to Google App Engine
Update:
This seems to be an issue with how the authentication is done in the example. It seems that it has changed since the example was written.

As a newcomer to the App engine, this is pretty confusing to wrap my head around.
Maybe it is really simple. I have at least been trying to figure out how I can change the code in _helpers.py
But instead of :

AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials'
I get:
AttributeError: 'module' object has no attribute 'ServiceAccountCredentials'

What I changed was:
 if key_file:
    key_data
= open(key_file, 'rb').read()
 
return oauth2client.ServiceAccountCredentials(
      email
, key_data, oauth.SCOPE)

Before it was:
     
  if key_file:
    key_data
= open(key_file, 'rb').read()
 
return oauth2client.client.SignedJwtAssertionCredentials(
    email
, key_data, oauth.SCOPE)

I was trying to follow recommendations from this on github
I've also been trying to understand the changes as they are explained here: https://github.com/google/oauth2client/issues/401

Maybe I'm way off here and the change is a pretty naive try to solve this...

//Michael

Nick (Cloud Platform Support)

unread,
Sep 22, 2016, 7:49:02 PM9/22/16
to Google App Engine
Hey Michael,

It appears you found an issue in the "trendy lights" demo. You should file an issue on the github repo and link this thread for context. It seems you did indeed find the source of the issue in the changed name of the function.

Cheers,

Nick
Cloud Platform Community Support

Michael Johansson

unread,
Sep 23, 2016, 9:52:50 AM9/23/16
to Google App Engine
Thank you for the reply. I will file an issue there and keep you updated with what I find out or learn.

I also tried another server example, I got the exact same error. Since I am using the same earth engine library, it might be an issue with that API. When I know more I will post in the earth engine developers forum as well.
Because as of now I feel that I am guessing a lot :)

During the weekend I will also try to run the examples in a linux environment, if it is a Earth engine API issue, I guess it might not work there as well.

Best regards
//Michael

Michael Johansson

unread,
Oct 3, 2016, 8:55:00 AM10/3/16
to Google App Engine
I have now tried the example in a Linux environment (Ubuntu 16.04.1 LTS).
After installing all required prerequisites to just get the environment up and running, I ran the build.sh and the examples ran pretty smoothly thereafter. This does tell me that something in the Earth Engine API as of now is not really working well in windows, or at least is a bit convoluted to get running.

I did discuss the issue on the GIT repository issue tracker but didn't really get closer to a solution.
I will post about this in the Earth Engine Developers group.

//Best regards
Michael

Levi Baber

unread,
Oct 13, 2016, 5:48:45 PM10/13/16
to Google App Engine
I'm running into a similar issue.  I think the only reason the example worked for you on Linux is because the build.sh is specifically pulling down version 1.3.2 of the oauth2client from github. I have tried using the latest earthengine-api available from pip, and the latest google-app-engine SDK and google-cloud-sdk and the problem is there as well. 

From what I can tell, the earth-engine _helpers.py is using the old method and needs to be updated to use the new ServiceAccountCredentials method. 

Michael Johansson

unread,
Oct 14, 2016, 5:20:55 AM10/14/16
to Google App Engine
Yeah, that seems to be the issue. Did you manage to update the earth-engine_helpers.py so that it is working?
I really tried but didn't get it to work. It just returned


AttributeError: 'module' object has no attribute 'ServiceAccountCredentials'

I haven't been trying more though since it was working on my current platform.
But it would be nice to be able to find a solution to this.

//Michael

Simon Bloch

unread,
Jul 10, 2019, 1:35:51 PM7/10/19
to Google App Engine
This thread is 3 years old, but I recently encountered and overcame a similar issue. For me it was an issue with where I installed the ee module to begin with. I explained my fix here: https://stackoverflow.com/a/56974809

Hope y'all are doing well!
-Simon 
Reply all
Reply to author
Forward
0 new messages