我有一个 Django 服务,我最近在其中添加了 OneLogin SSO。一切都在本地机器上工作正常,但在服务器上,登录视图在每个请求上都会抛出这个 ImportError 。
ImportError: Interpreter change detected - this module can only be loaded into one interpreter per process.
完整的堆栈跟踪是
Traceback (most recent call last):
File "/.virtualenvs/dj/local/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/.virtualenvs/dj/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 172, in _get_response
resolver_match = resolver.resolve(request.path_info)
File "/.virtualenvs/dj/local/lib/python3.5/site-packages/django/urls/resolvers.py", line 267, in resolve
for pattern in self.url_patterns:
File "/.virtualenvs/dj/local/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/.virtualenvs/dj/local/lib/python3.5/site-packages/django/urls/resolvers.py", line 310, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/.virtualenvs/dj/local/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/.virtualenvs/dj/local/lib/python3.5/site-packages/django/urls/resolvers.py", line 303, in urlconf_module
return import_module(self.urlconf_name)
File "/.virtualenvs/dj/lib64/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "./service/urls.py", line 23, in <module>
from service.apps.onelogin_sso import views as onelogin_views
File "./service/apps/onelogin_sso/views.py", line 9, in <module>
from onelogin.saml2.auth import OneLogin_Saml2_Auth
File "/.virtualenvs/dj/local/lib/python3.5/site-packages/onelogin/saml2/auth.py", line 14, in <module>
import xmlsec
ImportError: Interpreter change detected - this module can only be loaded into one interpreter per process.
我将 python 3.5.1 与 Django 1.11 和python3-saml
SSO 一起使用。该机器使用亚马逊 AMI 在 AWS 上。