【发布时间】:2018-12-26 21:28:02
【问题描述】:
我通过 GitHub 将本地开发的 Django Web 应用程序部署到 azure 中,当我尝试运行 URL 时,web.config 文件中出现以下错误
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:\home\python364x64\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\home\python364x64\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "D:\home\python364x64\wfastcgi.py", line 605, in get_wsgi_handler
handler = handler()
File ".\ptvs_virtualenv_proxy.py", line 107, in get_venv_handler
handler = get_wsgi_handler(os.getenv('WSGI_ALT_VIRTUALENV_HANDLER'))
File ".\ptvs_virtualenv_proxy.py", line 65, in get_wsgi_handler
handler = handler()
File "D:\home\site\wwwroot\env\lib\site-packages\django\core\wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "D:\home\site\wwwroot\env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\home\site\wwwroot\env\lib\site-packages\django\apps\registry.py", line 81, in populate
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
StdOut:
StdErr:
这是我的 web.config 文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off" />
</system.web>
<appSettings>
<add key="WSGI_ALT_VIRTUALENV_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
<add key="WSGI_ALT_VIRTUALENV_ACTIVATE_THIS" value="D:\home\site\wwwroot\env\Scripts\python.exe" />
<add key="WSGI_HANDLER" value="ptvs_virtualenv_proxy.get_venv_handler()" />
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
<add key="DJANGO_SETTINGS_MODULE" value="FinTech.settings" />
<add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
</appSettings>
<system.webServer>
<httpErrors errorMode="Detailed" />
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python364x64\python.exe|D:\home\python364x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
<rewrite>
<rules>
<rule name="Static Files" stopProcessing="true">
<conditions>
<add input="true" pattern="false" />
</conditions>
</rule>
<rule name="Configure Python" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
</conditions>
<action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我的代码有问题还是我需要安装一些额外的要求?我在尝试在 Azure 中运行 django Web 应用程序时遇到此错误,当我在本地运行我的 Web 应用程序时它工作正常。
【问题讨论】:
-
建议您检查下面的 GitHub 链接,并确保您的 web.config 和所有其他文件没有任何冲突数据等,github.com/MicrosoftDocs/azure-docs/blob/master/articles/…
-
我试过了,但错误仍然没有改变。当我打开我的 azure 应用程序的控制台并运行“manage.py runserver”时,它给了我一个错误为“Traceback(最近一次调用最后一次):文件“D:\home\site\wwwroot\manage.py”,第 12 行,在
中“无法导入 Django。您确定它已安装并且“ ImportError:无法导入 Django。您确定它已安装并在您的 PYTHONPATH 环境变量中可用吗?您忘记激活虚拟环境了吗?”
标签: django azure web-config