为什么我仍然收到错误:"CryptoUnavailableError: No crypto library available" Python 中?



我正试图通过Python对谷歌的DFA进行API调用,并使用他们建议的代码。但是,它仍然没有说明凭证对象已定义,并抛出错误:

Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File "C:Python27libsite-packagesoauth2clientutil.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:Python27libsite-packagesoauth2clientclient.py", line 1502, in __init__
    _RequireCryptoOrDie()
  File "C:Python27libsite-packagesoauth2clientclient.py", line 1456, in _RequireCryptoOrDie
    raise CryptoUnavailableError('No crypto library available')
CryptoUnavailableError: No crypto library available

我已经安装了pyOpenSSL库,pycrypto库与VCForPython编译器。我还设法编辑了eclipse客户机中的所有3个app.yaml文件,以附加:

libraries:
- name: pycrypto
  version: "latest"

对于任意凭证,我的代码是这样的:

import json    
import sys    
import apiclient    
from oauth2client import crypt    
import ssl    
import urllib2    
from OpenSSL import crypto    

HAS_OPENSSL = False    
HAS_CRYPTO = False    
try:    
  from oauth2client import crypt    
  HAS_CRYPTO = True    
  if crypt.OpenSSLVerifier is not None:    
    HAS_OPENSSL = True    
except ImportError:    
  pass

from oauth2client.client import SignedJwtAssertionCredentials    
client_email = 'example.apps.googleusercontent.com'    
with open("C:My Project-1234.p12") as f:    
        private_key = f.read()     

credentials = SignedJwtAssertionCredentials(client_email, private_key,
    'https://www.googleapis.com/auth/dfareporting')    
from httplib2 import Http
我意识到一开始可能有些多余。我没能通过这一步。

我觉得我已经尝试了一切,仍然被抛出'no crypto library'错误。

有人能帮忙吗?谢谢你!

PS -我使用Windows 7和Python 2.7和LiClipse。

上面的方法是将API调用作为"服务"Google帐户。我重新尝试了一个带有新凭据的"已安装应用程序"帐户和一种不同的方式来进行不需要任何加密类型库的API调用。

最新更新