从 iPython 发出 运行 ga.read_ga

Issue running ga.read_ga from iPython

我已经 运行 解决 运行ning 来自 iPython notebook 的代码问题。这是代码 运行:

import pandas.io.ga as ga
import gflags

df = ga.read_ga(['visits', 'avgTimeOnSite'], 
                         dimensions=['date', 'hour'], 
                         start_date='2012-10-25')

这是由此产生的错误:

C:\Users\bdoherty\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\auth.pyc in authenticate(flow, storage)
    106     credentials = storage.get()
    107     if credentials is None or credentials.invalid:
--> 108         credentials = tools.run_flow(flow, storage)
    109 
    110     http = credentials.authorize(http)

AttributeError: 'module' object has no attribute 'run'

查看 auth.py 的源代码,没有定义函数 运行() 但有一个 run_flow 函数,这里的问题是什么,为什么要尝试调用 运行()。如果这是一个明显的问题,请提前致歉,只是开始使用 GA 和 python

看起来正在使用库 pandas 中的 deprecated run() function was removed on Aug 25

Pandas 需要更新他们的代码以使用替换: tools.run_flow(流、存储、标志)

如果您有一个带有 pandas 存储库的工作测试环境,您可能可以使用 this method.

成功提交拉取请求

或者,您可以检查旧版本的 oauth2client。

向 Pandas 的所有者提交工单,将 pandas/io/auth.py 的(当前)第 108 行从 run() 更改为 run_flow(),或者自己进行修复并提交 PR。

对于其他开发者 运行 进入此错误:如果您有最新版本(as of Feb 2016) of the Google APIs Client Library for Python, just rename your call from tools.run() to tools.run_flow(), and you should be good-to-go. More about this change in a PSA (public service announcement) blogpost 我在 2015 年年中回信但定期更新以保持最新。

升级客户端库的最快方法是: pip install -U google-api-python-client # or pip3 for 3.x