【问题标题】:Issue running ga.read_ga from iPython从 iPython 运行 ga.read_ga 的问题
【发布时间】:2015-12-07 21:02:41
【问题描述】:

我在运行 iPython 笔记本中的代码时遇到了问题。这是运行的代码:

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(),但有一个 run_flow 函数,这里有什么问题,为什么它试图调用 run()。如果这是一个明显的问题,请提前道歉,只是开始使用 GA 和 python

【问题讨论】:

    标签: python google-analytics ipython google-api-python-client


    【解决方案1】:

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

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

    如果您有一个使用 pandas 存储库的工作测试环境,您可能可以使用 this method 成功提交拉取请求。

    或者,您可以签出旧版本的 oauth2client。

    【讨论】:

      【解决方案2】:

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

      对于遇到此错误的其他开发人员:如果您拥有最新版本 (as of Feb 2016) 的 Google APIs Client Library for Python,只需将您的呼叫从 tools.run()重命名tools.run_flow(),然后您应该很好去。 PSA(公共服务公告)blogpost 中有关此更改的更多信息,我在 2015 年年中回信,但会定期更新以保持最新状态。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-07-01
        • 1970-01-01
        • 2017-06-30
        相关资源
        最近更新 更多