Below is the code

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')

Below is the error

TypeError: cannot instantiate ctype 'EVP_MD_CTX' of unknown size

Based on this blog

Using this google-api-python-client

3

There are 3 answers

5
wi3o On

The google-api-python-client that I installed (link above) only works with python2. As of today, it doesn't work with python2 inside of conda env, only outside of conda env, and doesn't work with python 3.5.

1
Chemary On

I found this post oauth2client relating the problem, in my case the problem was solved updating to latest version of pyOpenSSL, 16.2.0 at the time of writing.

0
Saurav On

I don't have the points to upvote but Chemary's answer worked for me. I am using python 3.5. I faced the same issue and it got resolved when I installed pyOpenSSL.

pip install --upgrade pyOpenSSL