我想用我的地方dev_appserver本地连接的BigQuery API,下面这个教程:https://developers.google.com/bigquery/authorization?hl=de#service-accounts 运行此网站上提到的代码,返回一个ImportError:命名OpenSSL.crypto和导入错误无模块:SignedJwtAssertionCredentials
ImportError: cannot import name SignedJwtAssertionCredentials
所以我也跟着错误和发现(在oauth2client/client.py):
if HAS_CRYPTO:
# PyOpenSSL and PyCrypto are not prerequisites for oauth2client, so if it is
# missing then don't create the SignedJwtAssertionCredentials or the
# verify_id_token() method.
class SignedJwtAssertionCredentials(AssertionCredentials):
但我需要 “SignedJwtAssertionCredentials”!所以我孤立的错误进一步发现(在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我的代码。路径:
['/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']
无论如何,既不增加"/usr/local/lib/python2.7/site-packages/OpenSSL"
移到sys.path也不符号链接/usr/local/lib/python2.7/site-packages/OpenSSL
下/Users/mattes/Developer/gae-projects/project123
修复此问题。
/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
的Mac 10.9小牛的Python 2.7.5
有人能帮忙吗?
“oauth2client”模块位于何处?它在你的apppengine项目文件夹中吗? –
是的。从https://code.google.com/p/google-api-python-client/downloads/detail?name=google-api-python-client-gae-1.2.zip&can=2&q= – mattes
下载解释器无法加载具有C代码的Python模块;它是一个“纯粹的”Python环境。“ (https://developers.google。com/appengine/docs/python /#Python_Introduction)或许crypto.so文件是问题所在? – mattes