Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 没有名为OpenSSL.crypto和ImportError的模块:SignedJwtAssertionCredentials_Python_Google App Engine_Google Oauth_Google Bigquery - Fatal编程技术网

Python 没有名为OpenSSL.crypto和ImportError的模块:SignedJwtAssertionCredentials

Python 没有名为OpenSSL.crypto和ImportError的模块:SignedJwtAssertionCredentials,python,google-app-engine,google-oauth,google-bigquery,Python,Google App Engine,Google Oauth,Google Bigquery,根据本教程,我正在尝试使用本地dev_appserver本地连接到BigQuery API: 运行此站点上提到的代码,将返回以下错误: ImportError: cannot import name SignedJwtAssertionCredentials 因此,我跟踪了错误并发现(在oauth2client/client.py中): 但我需要“签名JWTAssertionCredentials”!因此,我进一步隔离了错误,并发现(在oauth2client/crypt.py中)这一行实际上

根据本教程,我正在尝试使用本地dev_appserver本地连接到BigQuery API: 运行此站点上提到的代码,将返回以下错误:

ImportError: cannot import name SignedJwtAssertionCredentials
因此,我跟踪了错误并发现(在oauth2client/client.py中):

但我需要“签名JWTAssertionCredentials”!因此,我进一步隔离了错误,并发现(在oauth2client/crypt.py中)这一行实际上导致了这个问题:

from OpenSSL import crypto
我试过:

$ python
>>> import OpenSSL
>>> OpenSSL.__file__
'/usr/local/lib/python2.7/site-packages/OpenSSL/__init__.pyc'
>>> from OpenSSL import crypto
>>> crypto.__file__
'/usr/local/lib/python2.7/site-packages/OpenSSL/crypto.so'
这看起来很有希望,还检查了我代码的sys.path:

['/Users/mattes/Developer/gae-projects/project123', 
 '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine', 
 '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine', 
 '/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 
 '/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2', 
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/protorpc-1.0', 
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webob-1.1.1', 
'/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/yaml-3.10']
无论如何,无论是在sys.path中添加
“/usr/local/lib/python2.7/site packages/OpenSSL”
,还是在
/Users/mattes/Developer/gae projects/project123
下对
/usr/local/lib/python2.7/site packages/OpenSSL
进行符号链接,都不能解决此问题

/usr/local/lib/python2.7/site packages/OpenSSL
看起来像:

├── SSL.so
├── __init__.py
├── __init__.pyc
├── crypto.so
├── rand.so
├── test
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── test_crypto.py
│   ├── test_crypto.pyc
│   ├── test_rand.py
│   ├── test_rand.pyc
│   ├── test_ssl.py
│   ├── test_ssl.pyc
│   ├── util.py
│   └── util.pyc
├── tsafe.py
├── tsafe.pyc
├── version.py
└── version.pyc
使用Mac10.9Mavericks和Python2.7.5


有人能帮忙吗?

通过将
pycrypto
添加到我的
应用程序的
部分,解决了这个问题。yaml

libraries:

- name: pycrypto
  version: "latest"

要在GAE服务器上运行此功能,我发现有三个步骤是必要的:

  • 安装最新版本的(或至少安装oauth2client模块)。请注意,它们提供了针对GAE的下载

  • 将my.p12密钥文件转换为.pem格式(使用openssl命令行工具)

  • 将PyCrypto库添加到app.yaml

    libraries:
      - name: pycrypto
        version: "2.6"  # this could be "latest" if you are daring
    

  • 对于dev_appserver,还需要在本地安装PyCrypto库,因为它不包含在SDK中。(API客户端库也支持OpenSSL,但我假设使用PyCrypto更接近运行时环境。)

    oauth2client
    模块位于何处?它在你的apppengine项目文件夹中吗?是的。从“解释器无法用C代码加载Python模块;这是一个“纯”Python环境。”()下载,因此可能是crypto.So文件有问题吗?“Python运行时环境的所有代码都必须是纯Python,并且不包括任何C扩展名或其他必须编译的代码。”对于我来说,
    pycparser/u init_uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuupy
    ,作为
    PyCrypto
    的依赖项包含,正在尝试导入
    subprocess.Popen
    ,在App Engine python环境中,此操作失败。这导致
    HAS_CRYPTO
    签入
    oauth2client/client.py
    失败,因此未定义
    SignedJwtAssertionCredentials
    。(我用的是mac。)@EricWalker我的mac和你有同样的问题。你解决了吗?@poiuytrez,我已经有一段时间没有处理这个问题了,但我记得我终于让它工作了。我不记得我做了什么。将pycrypto添加到你的应用程序。yaml做了什么?它是否强制更新Python OpenSSL包装器?
    openssl pkcs12  -nocerts -in cert.p12 -out cert.pem
    
    libraries:
      - name: pycrypto
        version: "2.6"  # this could be "latest" if you are daring