Using SignedJwtAssertionCredentials in Python Google App Engine

Used the code snippet below to edit spreadsheet cells in my google drive account. This works when I run the code from my python IDE (not google engine).

import webapp2
import gspread
from oauth2client.client import SignedJwtAssertionCredentials
import json
from httplib2 import Http
from gspread.exceptions import CellNotFound
import os

# folder = os.path.dirname(os.path.realpath(__file__))
# file_path = os.path.join(folder, 'clientkey.json')
json_key = json.load(open('clientkey.json'))
scope = ['https://spreadsheets.google.com/feeds']
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
googleClient = gspread.authorize(credentials)

      

When copying the same code to my google engine project that I have to deploy, it shows below error.

    Traceback (most recent call last):

  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\CrowdStar\workspace\AppEngineThinkStudio\DominicProject\main.py", line 3, in <module>

    from oauth2client.client import SignedJwtAssertionCredentials

  File "C:\Users\CrowdStar\workspace\AppEngineThinkStudio\DominicProject\oauth2client\client.py", line 34, in <module>

    import six

ImportError: No module named six

      

I added the required module, it throws an error saying another module is required. Watch out for adding the required modules and it keeps throwing an error to add another module. Added more than 8 modules to make it work and it still says that some modules won't be found even though they work well outside of the application. How to fix it.

+3


source to share


1 answer


I see this is an old question too, but unanswered and still getting views. This will happen if you only install the client library on your system package sites like this:

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

      



To share the library along with all the required dependencies in your application directory so that they are loaded with your application, use the "-t" flag:

pip install google-api-python-client -t /myappdir

      

0


source







All Articles