【问题标题】:Error occurred while reading WSGI handler: Error读取 WSGI 处理程序时发生错误:错误
【发布时间】:2022-01-28 02:01:22
【问题描述】:

我想打开django项目的时候遇到这样的错误。我的 django 项目在同一台服务器上运行,但我在上次打开的站点上遇到了这样的错误。

web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <handlers>
   <add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="c:\python39\python.exe|c:\python39\lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
 </handlers>    
 <tracing>
  <traceFailedRequests>
    <clear />
  </traceFailedRequests>
 </tracing>
</system.webServer>
<appSettings>
<add key="WSGI_HANDLER" value="umy.wsgi.application" />
<add key="DJANGO_SETTINGS_MODULE" value="umy.settings" />
<add key="PYTHONPATH" value="C:\Inetpub\vhosts\domain.com\httpdocs" />
</appSettings>
<system.web>
<compilation tempDirectory="C:\Inetpub\vhosts\domain.com\tmp" />
</system.web>
</configuration>

我得到的错误是关于;

Error occurred while reading WSGI handler:

Traceback (most recent call last):
File "c:\python39\lib\site-packages\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "c:\python39\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "c:\python39\lib\site-packages\wfastcgi.py", line 616, in get_wsgi_handler
raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb))
ValueError: "umy.wsgi.application" could not be imported: Traceback (most recent call last):
File "c:\python39\lib\site-packages\wfastcgi.py", line 600, in get_wsgi_handler
handler = __import__(module_name, fromlist=[name_list[0][0]])
File ".\umy\wsgi.py", line 9, in <module>
application = get_wsgi_application()
File "c:\python39\lib\site-packages\django\core\wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "c:\python39\lib\site-packages\django\core\handlers\wsgi.py", line 127, in __init__
self.load_middleware()
File "c:\python39\lib\site-packages\django\core\handlers\base.py", line 40, in load_middleware
middleware = import_string(middleware_path)
File "c:\python39\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
module = import_module(module_path)
File "c:\python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'htmlmin'



StdOut: 

StdErr: 

对不起我的英语不好

【问题讨论】:

  • 请在settings.py中显示MIDDLEWARE列表
  • htmlmin 安装库后问题解决了。
  • 如果我的回复有帮助,请采纳为答案(点击回复旁边的标记选项将其从灰色切换为填写。),请参阅meta.stackexchange.com/questions/5234/…

标签: python django iis webdeploy


【解决方案1】:

请按照以下步骤解决问题。

步骤1.点击Handler Mappings,找到FastCgi,点击Edit,将Executable(optional)的值修改为virtualenv路径。

C:\inetpub\wwwroot\project_name\virtualenv\Scripts\python.exe|C:\inetpub\wwwroot\project_name\wfastcgi.py

步骤 2.打开FastCGI Settings,如下所示。

第 3 步。点击Environment Variables,并将下方添加到集合中。

Name: WSGI_HANDLER
Value: django.core.wsgi.get_wsgi_application()


(Django porject path)
Name: PYTHONPATH Value:
C:\inetpub\wwwroot\project_name


(Prohect settings path)
Name: DJANGO_SETTINGS_MODULE
Value: project_name.settings

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 2016-08-18
    • 1970-01-01
    相关资源
    最近更新 更多