我正在尝试在Google App Engine上运行一个简单的python脚本。如何安装Google AnalyticsAPI库?
图书馆:https://developers.google.com/api-client-library/python/apis/analytics/v3
说明:https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring
我已经尝试了所有东西,但无法运行,即使它可以在我的电脑上运行。我现在拥有的是: 根文件夹中的python脚本, 在/ lib文件夹中,我复制了从我的PC安装的文件夹(/ googleapiclient和/google_api_python_client-1.4.0-py2.7.egg-info) 我在/ lib文件夹中有appengine_config.py,其中包含:
from google.appengine.ext import vendor
# Add any libraries installed in the "lib" folder.
vendor.add('lib')
vendor.add('google-api-client')
app.yaml文件:
application: psyched-cab-861
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: hello_analytics_api_v3.app
回溯:
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
新日志:
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
我尝试将appengine_config.py文件编辑为
vendor.add('googleapiclient') #The name of the file
我在GAE中编辑它,然后单击提交,它会保存,但我得到与上面相同的错误与vendor.add('google-api-python-client')错误。为什么文件没有更新?
答案 0 :(得分:3)
正如docs所说:将appengine_config.py
放在应用程序的 root 文件夹中(而不是 / lib 文件夹中)。
顺便说一下,库的名称是google-api-python-client
而不是google-api-client
。
然后您必须在 / lib 文件夹中安装google-python-api-client
:
$ pip install -t lib google-api-python-client