我试图在较旧的Windows服务器(带有Service Pack 1的Windows Server 2008 R2)上使用IIS托管Django应用程序(Django 2.1.4,Python 3.6)。我已经成功地将其部署在测试服务器(相同的操作系统)上,可以将其部署到生产环境中,但是我在这里遇到了问题。我遵循了在登台服务器上使用的相同配置步骤,但是现在当我尝试访问主站点时,在尝试导入_ssl时,出现以下错误ImportError: DLL load failed: The specified module could not be found.
(下面的完整堆栈跟踪)。这是使用Okta身份验证以及通过网站启用电子邮件的要求。
我已经在虚拟环境中安装了所有依赖项,并将IIS配置为使用该环境。我通过多个venv和一个conda环境来做到这一点,但都没有运气。如果我注释掉使用Okta的代码部分,则该应用程序可以正常工作,直到达到向用户发送电子邮件的地步为止,此时我也面临相同的问题。另外,如果我使用manage.py runserver
的Django开发服务器,则Okta和电子邮件功能都可以正常工作。我还确保该应用程序以具有对应用程序和虚拟环境的完全权限的用户身份运行。我还能够确认_ssl.pyd实际上在虚拟环境中。
我假设由于某种原因IIS无法找到或访问_ssl.pyd,因此,如果有人知道为什么会发生这种情况,或者是由其他原因造成的,我一定会感谢您的帮助!
Traceback (most recent call last):
File "C:\ACD_Django\envs\django\Lib\site-packages\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "C:\ACD_Django\envs\django\Lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "C:\ACD_Django\envs\django\Lib\site-packages\wfastcgi.py", line 616, in get_wsgi_handler
raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb))
ValueError: "django.core.wsgi.get_wsgi_application()" could not be imported: Traceback (most recent call last):
File "C:\ACD_Django\envs\django\Lib\site-packages\wfastcgi.py", line 605, in get_wsgi_handler
handler = handler()
File "C:\ACD_Django\envs\django\lib\site-packages\django\core\wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "C:\ACD_Django\envs\django\lib\site-packages\django\core\handlers\wsgi.py", line 136, in __init__
self.load_middleware()
File "C:\ACD_Django\envs\django\lib\site-packages\django\core\handlers\base.py", line 34, in load_middleware
middleware = import_string(middleware_path)
File "C:\ACD_Django\envs\django\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
module = import_module(module_path)
File "C:\Users\mmitcdba\AppData\Local\Continuum\miniconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\ACD_Django\envs\django\lib\site-packages\mozilla_django_oidc\middleware.py", line 21, in <module>
from mozilla_django_oidc.auth import OIDCAuthenticationBackend
File "C:\ACD_Django\envs\django\lib\site-packages\mozilla_django_oidc\auth.py", line 20, in <module>
from josepy.jwk import JWK
File "C:\ACD_Django\envs\django\lib\site-packages\josepy\__init__.py", line 44, in <module>
from josepy.interfaces import JSONDeSerializable
File "C:\ACD_Django\envs\django\lib\site-packages\josepy\interfaces.py", line 8, in <module>
from josepy import errors, util
File "C:\ACD_Django\envs\django\lib\site-packages\josepy\util.py", line 4, in <module>
import OpenSSL
File "C:\ACD_Django\envs\django\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "C:\ACD_Django\envs\django\lib\site-packages\OpenSSL\crypto.py", line 16, in <module>
from OpenSSL._util import (
File "C:\ACD_Django\envs\django\lib\site-packages\OpenSSL\_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "C:\ACD_Django\envs\django\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 172, in <module>
Binding.init_static_locks()
File "C:\ACD_Django\envs\django\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 142, in init_static_locks
__import__("_ssl")
ImportError: DLL load failed: The specified module could not be found.
StdOut:
StdErr: