Adam12344
Adam12344

Reputation: 1053

Adding Google Analytics API Library to Google App Engine

I am trying to run a simple python script on Google App Engine. How do I install the Google Analytics API library?

Library: https://developers.google.com/api-client-library/python/apis/analytics/v3

Instructions: https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring

I've tried everything and can't get this to run, even though it works on my pc. What I have right now is: The python scripts in the root folder, In the /lib folder I copied the folders that were installed from my PC (/googleapiclient and /google_api_python_client-1.4.0-py2.7.egg-info) And I have appengine_config.py in /lib folder which contains:

from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('lib')
vendor.add('google-api-client')

app.yaml file:

application: psyched-cab-861
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: hello_analytics_api_v3.app

Traceback:

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
ImportError: No module named helloworld

New Log:

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/lib_config.py", line 354, in __getattr__
    self._update_configs()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/lib_config.py", line 290, in _update_configs
    self._registry.initialize()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/lib_config.py", line 165, in initialize
    import_func(self._modname)
  File "/base/data/home/apps/s~just-terminus-94303/1.384249106864280829/appengine_config.py", line 5, in <module>
    vendor.add('google-api-python-client')
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/vendor/__init__.py", line 44, in add
    'No such virtualenv or site directory' % path)
ValueError: virtualenv: cannot access google-api-python-client: No such virtualenv or site directory

I tried editing the appengine_config.py file to

vendor.add('googleapiclient')  #The name of the file

I edit it in GAE, and click commit, it saves, but I get the same error as above with the vendor.add('google-api-python-client') error. Why is the file not updating?

Upvotes: 2

Views: 1506

Answers (1)

doru
doru

Reputation: 9110

As the docs say: put the appengine_config.py in your root folder of the application (and not in the /lib folder). By the way, the name of the library is google-api-python-client and not google-api-client.

Then you have to install google-python-api-client in your /lib folder:

$ pip install -t lib google-api-python-client

Upvotes: 3

Related Questions