一点背景:我一直在尝试创建一个可以通过管理API查询和插入的安静服务器.在使用node.js和javascript将我的头撞到墙上之后,我切换到python知道它有更多的支持.
目前,我正在尝试按照GA 教程:Hello Analytics API略微扭曲.我尝试访问服务器上的特定端点时触发了该main
方法hello_analytics_api_v3.py
.这仅用于测试.调用此方法insertExperiment
并尝试将实验插入私有Google Analytics帐户.
但是我总是收到例外:
NotImplementedError('The gflags library must be installed to use tools.run(). Please install gflags or preferrably switch to using tools.run_flow().',)
这是完整的跟踪堆栈:
在_handle中输入"/0zzz/bottle.py",第764行
return route.call(**args)在包装器中输入"/0zzz/bottle.py",第1575行
rv = callback(*a, **ka)在server_static中输入第39行的"server.py"
hello_analytics_api_v3.insertExperiment("xxxxxxx", "xxxxxxxxx", "xxxxxx", experiment_body)在insertExperiment中输入第11行"/0zzz/hello_analytics_api_v3.py"
service = hello_analytics_api_v3_auth.initialize_service()在initialize_service中输入第32行的文件"/0zzz/hello_analytics_api_v3_auth.py"
credentials = prepare_credentials()在prepare_credentials中输入第25行的文件"/0zzz/hello_analytics_api_v3_auth.py"
credentials = run(FLOW, storage)在运行中文件"/0zzz/oauth2client/tools.py",第241行
'The gflags library must be installed to use tools.run(). 'NotImplementedError:必须安装gflags库才能使用tools.run().请安装gflags或者最好切换到使用tools.run_flow().
一些额外的说明:
main
在复制教程中的确切代码时,我尝试了同样的事情(调用ping正确的地址).
我有使用管理API的写访问权限 - 所以这根本不是问题.
我以为我的一个库(也可以导入一个run
)可能存在命名空间问题,但是通过重命名另一个库解决了这个问题.
已安装GA客户端库!根据Hello Analytics API上的说明.
感谢您提供任何帮助!