2

下面是代码

import httplib2, argparse, os, sys, json
from oauth2client import tools, file, client
from oauth2client.service_account import ServiceAccountCredentials
from googleapiclient import discovery
from googleapiclient.errors import HttpError

scope = ['https://www.googleapis.com/auth/prediction','https://www.googleapis.com/auth/devstorage.read_only']

def get_api(api, scope, service_account=True):
     storage = file.Storage('oAuth2.json')
     creds = storage.get()

     if creds is None or creds.invalid:
        creds = ServiceAccountCredentials.from_json_keyfile_name('service_account.json',
                                                             scopes=scope)
        storage.put(creds)

     http = creds.authorize(httplib2.Http())
     return discovery.build(api, 'v1.6', http=http)

api = get_prediction_api('prediction')

下面是错误

TypeError:无法实例化未知大小的 ctype 'EVP_MD_CTX'

基于这个博客

使用这个google-api-python-client

4

3 回答 3

3

我发现这篇文章oauth2client与该问题有关,在我的情况下,问题已解决,在撰写本文时更新到 pyOpenSSL 的最新版本 16.2.0。

于 2017-01-04T13:21:13.440 回答
1

我安装的 google-api-python-client(上面的链接)仅适用于 python2。截至今天,它不适用于 conda env 内部的 python2,只能在 conda env 之外使用,并且不适用于 python 3.5。

于 2016-12-16T17:41:23.080 回答
-1

我没有点赞,但 Chemary 的回答对我有用。我正在使用 python 3.5。我遇到了同样的问题,当我安装 pyOpenSSL 时它得到了解决。

pip install --upgrade pyOpenSSL
于 2017-08-24T19:15:11.033 回答