ImportError: Interpreter change detected while importing xmlsec
ImportError: Interpreter change detected while importing xmlsec
我有一个 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。
机器在 AWS 上使用 amazon AMI。
事实证明,我们将 uwsgi 与线程一起使用,并且每个线程都在创建自己的解释器。
我们所要做的就是更新 uwsgi 应用程序的 ini file
以使用单一解释器。
single-interpreter = True
我有一个 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。
机器在 AWS 上使用 amazon AMI。
事实证明,我们将 uwsgi 与线程一起使用,并且每个线程都在创建自己的解释器。
我们所要做的就是更新 uwsgi 应用程序的 ini file
以使用单一解释器。
single-interpreter = True