导入错误:Google AnalyticsAPI授权

Fre*_*d91 9 python google-api google-analytics-api oauth-2.0 google-oauth

我正在尝试运行此处提供的示例https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-py进行授权.

我从SO中的其他问题中注意到(ImportError:无法导入名称SignedJwtAssertionCredentials)SignedJwtAssertionCredentials已被删除,因此无法导入.

因此,我开始遵循GitHub页面(https://github.com/google/oauth2client/issues/401)和StackOverflow 提供的解决方案.到目前为止,没有任何效果,我仍然看到同样的错误.以下是我的代码.

import argparse

from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials

import httplib2
from oauth2client import client
from oauth2client import file
from oauth2client import tools
Run Code Online (Sandbox Code Playgroud)

而且,这是我在运行上述代码时收到的错误.

ImportError: cannot import name ServiceAccountCredentials
Run Code Online (Sandbox Code Playgroud)

由于我是这个领域的全新手,我试着为OAuth(2.0.0和1.5.2)这两个版本做到这一点.我也在安装后尝试过pyopenssl,但仍然失败了.

sch*_*fle 15

似乎oauth2client安装不成功.尝试

pip install --upgrade google-api-python-client

  • 这可能有很多原因无法奏效.检查此链接是否存在可能出错的问题.http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html (3认同)
  • 它已成功安装.2.0.0.版. (2认同)