gpt4 book ai didi

python - 值错误: "hostingstart.app" could not be imported

转载 作者:行者123 更新时间:2023-12-01 08:25:13 25 4
gpt4 key购买 nike

尝试为 Flask python 创建 azure python Web 应用程序,但出现以下错误

Error occurred while reading WSGI handler:

Traceback (most recent call last): File "D:\Python34\Scripts\wfastcgi.py", line 711, in main
env, handler = read_wsgi_handler(response.physical_path) File "D:\Python34\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
return env, get_wsgi_handler(handler_name) File "D:\Python34\Scripts\wfastcgi.py", line 551, in get_wsgi_handler
raise ValueError('"%s" could not be imported' % handler_name) ValueError: "hostingstart.app" could not be imported

标准输出:

标准错误:

我尝试升级 wfastcgi,之后我将脚本位置更改为新的 wfastcgi,它抛出脚本处理程序 scriptProcessor 无法找到错误

文件夹结构:

WWWroot
- hostingstart.py
- view.py
- web.config

托管启动.py

from flask import Flask
app = Flask(__name__)

import view
wsgi_app = app.wsgi_app

Web.Config

<configuration>   <appSettings>
<add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
<add key="WSGI_HANDLER" value="hostingstart.app"/>
<add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/> </appSettings> <system.webServer>
<httpErrors errorMode="Detailed"></httpErrors>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule"
scriptProcessor="D:\Python34\python.exe|D:\Python34\Scripts\wfastcgi.py"
resourceType="Unspecified" requireAccess="Script" />
</handlers> </system.webServer> </configuration>

最佳答案

您可以尝试按照以下步骤安装python扩展版本,而不是使用azure web应用自带的版本。

第1步:添加扩展(这里是Python 3.6.1 x64)

enter image description here

第 2 步:发布您的 flask 项目并添加 web.config

网络配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="<Your Project Name>.app"/>
<add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
<add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
</appSettings>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\Python361x64\python.exe|D:\home\Python361x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
</system.webServer>
</configuration>

如果部署成功,您可以在 KUDU 路径中看到以下结构:D:\home\site\wwwroot>

enter image description here

如果你想使用额外的Python包,请继续。

第3步:切换到Kudu CMD并命令cd Python361x64touch get-pip.py并复制url内容https://通过编辑按钮将 bootstrap.pypa.io/get-pip.py 复制到 get-pip.py 中,然后运行 ​​python get-pip.py 进行安装点工具。

enter image description here

第 4 步:通过 python -m pip install pyodbc 安装您需要的任何软件包

enter image description here

关于python - 值错误: "hostingstart.app" could not be imported,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54300455/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com