Analytics API + Python Server, NotImplementedError Hello Analytics
google-analytics-api, python
Solution
I received the same error while running through a tutorial for google APIs called 'Google APIs Console Help'. The fix was simple in my case, just update the gflags library:
easy_install --upgrade python-gflags
Problem
A little background: I've been trying to make a restful server that can query and insert via the management API. After banging my head against the wall using node.js and javascript I switched over to python knowing it has more support. Currently I am trying to follow the GA Tutorial: Hello Analytics API with a slight twist. I trigger the what was the `main` method in `hello_analytics_api_v3.py` when trying to access a particular end point on the server. This is only for testing. The method is called `insertExperiment` and attempts to insert an experiment into a private Google Analytics account. However I'm always receiving the exception: `NotImplementedError('The gflags library must be installed to use tools.run(). Please install gflags or preferrably switch to using tools.run_flow().',)` Here is the full trace stack: File "/0zzz/bottle.py", line 764, in _handle ``` return route.call(**args) ``` File "/0zzz/bottle.py", line 1575, in wrapper ``` rv = callback(*a, **ka) ``` File "server.py", line 39, in server_static ``` hello_analytics_api_v3.insertExperiment("xxxxxxx", "xxxxxxxxx", "xxxxxx", experiment_body) ``` File "/0zzz/hello_analytics_api_v3.py", line 11, in insertExperiment ``` service = hello_analytics_api_v3_auth.initialize_service() ``` File "/0zzz/hello_analytics_api_v3_auth.py", line 32, in initialize_service ``` credentials = prepare_credentials() ``` File "/0zzz/hello_analytics_api_v3_auth.py", line 25, in prepare_credentials ``` credentials = run(FLOW, storage) ``` File "/0zzz/oauth2client/tools.py", line 241, in run ``` 'The gflags library must be installed to use tools.run(). ' ``` NotImplementedError: The gflags library must be installed to use tools.run(). Please install gflags or preferrably switch to using tools.run_flow(). A few extra notes: - I have tried this exact same thing (invoking `main` on pinging the correct address) when copying the exact code from the Tutorial. - I have write access with the management API -- so that's not a problem here at all. - I thought there might be a namespace issue with one of my libraries (which also imports a `run`) but resolved this by renaming the other library. - GA Client Library is installed! as per the instructions on Hello Analytics API. Thank you for any help you can provide!