Flask,Windows,IIS,Plotly-Dash.读取WSGI处理程序时发生错误 [英] Flask, Windows, IIS, Plotly-Dash. Error Occured While reading WSGI handler

查看:203
本文介绍了Flask,Windows,IIS,Plotly-Dash.读取WSGI处理程序时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望您能帮助我解决Flask中出现的错误,以尝试在Windows服务器上部署plot-dash.

I'm hoping you can help me with errors that I'm getting with Flask in an attempt to deploy plotly-dash on a Windows server.

我已经按照以下指南逐字设置了Flask,除了我的网站在wwwroot文件夹中的位置: IIS上的烧瓶

I've set up Flask using the following guide, verbatim, except the location of my website within the wwwroot folder: Flask on IIS

当我使用最基本的应用程序时,它可以正常工作,例如以下代码:

When I use the most basic of apps, it works fine, an example being the following code:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello from FastCGI via IIS!"

if __name__ == "__main__":
    app.run()

但是,如果我尝试稍微复杂一点的东西,例如基本的Dash演示:

But then if I try something slightly more complex, like the basic Dash demo:

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        figure={
            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
            }
        }
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)

我得到如下错误(为了便于解释,我试图对其进行整理):

I get an error as follows (which I've tried to tidy up for ease of interpretation):

Error occurred while reading WSGI handler: 
Traceback (most recent call last): 
    File "C:\inetpub\wwwroot\wfastcgi.py", line 791, in main env, handler = read_wsgi_handler(response.physical_path) 
    File "C:\inetpub\wwwroot\wfastcgi.py", line 633, in read_wsgi_handler handler = get_wsgi_handler(os.getenv("WSGI_HANDLER")) 
    File "C:\inetpub\wwwroot\wfastcgi.py", line 600, in get_wsgi_handler handler = __import__(module_name, fromlist=[name_list[0][0]]) 
    File ".\app.py", line 1, in import dash 
    File "C:\Python36\lib\site-packages\dash\__init__.py", line 1, in from .dash import Dash # noqa: F401 
    File "C:\Python36\lib\site-packages\dash\dash.py", line 12, in import plotly 
    File "C:\Python36\lib\site-packages\plotly\__init__.py", line 31, in from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools, 
    File "C:\Python36\lib\site-packages\plotly\plotly\__init__.py", line 10, in from . plotly import ( 
    File "C:\Python36\lib\site-packages\plotly\plotly\plotly.py", line 30, in from plotly import exceptions, files, session, tools, utils 
    File "C:\Python36\lib\site-packages\plotly\tools.py", line 59, in ipython_core_display = optional_imports.get_module('IPython.core.display') 
    File "C:\Python36\lib\site-packages\plotly\optional_imports.py", line 23, in get_module return import_module(name) 
    File "C:\Python36\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) 
    File "C:\Python36\lib\site-packages\IPython\__init__.py", line 55, in from .terminal.embed import embed 
    File "C:\Python36\lib\site-packages\IPython\terminal\embed.py", line 15, in from IPython.core.interactiveshell import DummyMod, InteractiveShell 
    File "C:\Python36\lib\site-packages\IPython\core\interactiveshell.py", line 61, in from IPython.utils import io 
    File "C:\Python36\lib\site-packages\IPython\utils\io.py", line 95, in stdin = IOStream(sys.stdin, fallback=devnull) 
    File "C:\Python36\lib\site-packages\IPython\utils\io.py", line 39, in __init__ for meth in filter(clone, dir(stream)): 
    File "C:\Python36\lib\site-packages\IPython\utils\io.py", line 38, in clone return not hasattr(self, meth) and not meth.startswith('_') 
    File "C:\Python36\lib\site-packages\IPython\utils\io.py", line 82, in closed return self.stream.closed 
    ValueError: underlying buffer has been detached StdOut: StdErr:

我已经进行了大量的谷歌搜索,并尽我最大的努力来解码此错误,但是我撞到了砖墙.有人有什么想法吗?

I've done a ton of googling and tried my best to decode this error, but I'm hitting a brick wall. Does anyone have any ideas?

根据@susodapop的建议,我删除了IPython,现在出现以下错误:

Following on from the suggestion by @susodapop I've removed IPython and now got the following error:

Error occurred: Traceback (most recent call last): File "C:\inetpub\wwwroot\wfastcgi.py", line 847, in main result = handler(record.params, response.start) 
TypeError: 'Dash' object is not callable StdOut: StdErr: C:\Python34\lib\site-packages\plotly\tools.py:103: UserWarning: Looks like you don't have 'read-write' permission to your 'home' ('~') directory or to our '~/.plotly' directory. 
That means plotly's python api can't setup local configuration files. No problem though! You'll just have to sign-in using 'plotly.plotly.sign_in()'. For help with that: 'help(plotly.plotly.sign_in)'. Questions? Visit https://support.plot.ly 

推荐答案

我遇到了类似的问题.这是我执行此操作的步骤:

I ran into similar issues. Here are the steps I ran to get this to work:

1)确保添加模块映射"可执行文件中的python.exe,管道和wfastcgi.py文件之间没有空格.参见链接进行解释.这给我带来了500错误.

1) Ensure there is no spaces between the python.exe, pipe, and wfastcgi.py file in the "Add Module Mapping" Executable. See this link for explanation. This threw a 500 error for me.

2)确保您使用的是flask应用程序实例,而不是破折号应用程序实例.请参见 Dash部署用户指南这是通过在WSGI_HANDLER环境中使用app.server而不是app.app来完成的.多变的.链接中的屏幕截图来自1..

2) Ensure you are using the flask app instance instead of the dash app instance. See Dash Deployment User Guide This is accomplished by using app.server instead of app.app in the WSGI_HANDLER environment variable. Screenshots in link from 1.

3)最后,如果您从原始问题中得到错误,请按照注释中的指示卸载IPython.

3) Lastly, uninstall IPython as indicated in comments if you get the error from the original question.

在这三个问题之后.我将仪表板应用程序部署在IIS上.

After these three issues. I got my dash app to deploy on IIS.

这篇关于Flask,Windows,IIS,Plotly-Dash.读取WSGI处理程序时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆