我在我的网站中使用 python-social-auth API 进行身份验证。
但我收到一个异常`无法导入名称 is_secure_transport。
下面是踪迹。
Django 1.7
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'social.apps.django_app.default',
'login')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/utils.py" in wrapper
49. backend, uri)
File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/utils.py" in load_backend
29. Backend = get_backend(BACKENDS, name)
File "/usr/local/lib/python2.7/dist-packages/social/backends/utils.py" in get_backend
51. load_backends(backends, force_load=True)
File "/usr/local/lib/python2.7/dist-packages/social/backends/utils.py" in load_backends
33. backend = module_member(auth_backend)
File "/usr/local/lib/python2.7/dist-packages/social/utils.py" in module_member
23. module = import_module(mod)
File "/usr/local/lib/python2.7/dist-packages/social/utils.py" in import_module
17. __import__(name)
File "/usr/local/lib/python2.7/dist-packages/social/backends/facebook.py" in <module>
12. from social.backends.oauth import BaseOAuth2
File "/usr/local/lib/python2.7/dist-packages/social/backends/oauth.py" in <module>
4. from requests_oauthlib import OAuth1
File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/__init__.py" in <module>
3. from .oauth2_auth import OAuth2
File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/oauth2_auth.py" in <module>
3. from oauthlib.oauth2 import is_secure_transport
Exception Type: ImportError at /login/google-oauth2/
Exception Value: cannot import name is_secure_transport
最佳答案
更新 oauthlib 版本肯定有效。
只需这样做:
sudo pip install --upgrade oauthlib
关于django - 无法导入名称 is_secure_transport,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26051677/