ValueError:“ django.core.wsgi.get_wsgi_application()”无法导入

问题描述 投票:2回答:2

我正在我的web.config文件中设置所有路径,并在IIS中(在Windows Server 2012 R2上)配置所有内容。完成后,我启动了服务器并访问了网站。但是这样做的时候,我得到了以下错误消息:

Error occurred while reading WSGI handler:

Traceback (most recent call last):
  File "C:\inetpub\wwwroot\djangoapp\wfastcgi.py", line 711, in main
    env, handler = read_wsgi_handler(response.physical_path)
  File "C:\inetpub\wwwroot\djangoapp\wfastcgi.py", line 568, in read_wsgi_handler
    return env, get_wsgi_handler(handler_name)
  File "C:\inetpub\wwwroot\djangoapp\wfastcgi.py", line 551, in get_wsgi_handler
    raise ValueError('"%s" could not be imported' % handler_name)
ValueError: "django.core.wsgi.get_wsgi_application()" could not be imported


StdOut: 

StdErr:

Web.config(文件):

 <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Python FastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="C:\Python34\python.exe|C:\inetpub\wwwroot\djangoapp\wfastcgi.py"
resourceType="Unspecified"
requireAccess="Script" />
</handlers>
</system.webServer>

<appSettings>
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
<add key="PYTHONPATH" value="C:\Python34\python.exe" />
<add key="WSGI_RESTART_FILE_REGEX" value=".*((\.py)|(\.config))$" />
<add key="DJANGO_SETTINGS_MODULE" value="djangoapp.settings" />
</appSettings>
</configuration>

我不明白为什么会发生此错误。有谁知道如何解决这个问题?

django iis windows-server-2012-r2 wfastcgi
2个回答
0
投票

这是我们之间的区别。

<add key="WSGI_HANDLER" value="django.core.handlers.wsgi.WSGIHandler()" />
<add key="PYTHONPATH" value="[PATH_OF_DJANGOAPP]" />

0
投票

我在网络上经常看到这个问题。这里的问题是您的计算机上有2个版本的Python。确保两个版本都安装了所有内容。例如,根据环境变量的设置方式,例如Python版本3.4:py -m pip install django和Python版本3.6:仅pip install django。请确保所有内容都已正确下载。还要注意,对于这两个版本,您还必须输入以下命令以使其起作用:对于版本3.6(以我为例):

pip install --upgrade wheel
pip install wfastcgi
wfastcgi-enable

对于3.4版本(以我为例):

py -m pip install --upgrade wheel
py -m pip install wfastcgi
wfastcgi-enable

注意,两个版本都有自己的wfastcgi。

© www.soinside.com 2019 - 2024. All rights reserved.