在Windows上运行Flask应用程序会引发“尝试在不是套接字的东西上的操作” [英] Running Flask app on Windows raises "an operation was attempted on something that is not a socket"

查看:195
本文介绍了在Windows上运行Flask应用程序会引发“尝试在不是套接字的东西上的操作”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当运行一个基本的Flask应用程序时,我在shell中发现了这个错误,并且找不到如何解决这个问题。

 在http://127.0.0.1:5000/上运行(按CTRL + C退出)< br /> 
使用stat重新启动< br />
调试器处于活动状态!< br />
调试器的pin码:295-257-376< br />线程1中的
异常:< br />
Traceback(最近的最后一次调用):< br />
文件C:\ Users \Admin\AppData\Local\Programs\Python\Python35-32\lib\threading.py,第923行,在_bootstrap_inner
self.run()<峰; br />
文件C:\ Users \Admin\AppData\Local\Programs\Python\Python35-32\lib\threading.py,行871,运行
self._target(* self._args,** self._kwargs)< br />
文件C:\ Users \Admin\AppData\Local\Programs\Python\Python35-32\lib\site-packages\werkzeug\serving.py,行656,在内部
fd = fd)< br />
文件C:\ Users \Admin\AppData\Local\Programs\Python\Python35-32\lib\site-packages\werkzeug\serving.py,行550,在make_server
passthrough_errors,ssl_context,fd = fd)< br />
文件C:\ Users \Admin\AppData\Local\Programs\Python\Python35-32\lib\site-packages\werkzeug\serving.py,行462,在__init__
socket.SOCK_STREAM)< br />
文件C:\ Users \Admin\AppData\Local\Programs\Python\Python35-32\lib\socket.py,第446行,fromfd
nfd = dup(fd)< br />
OSError:[WinError 10038]一个操作尝试的东西是不是一个插座





  from flask import Flask,render_template 
$ b app = Flask(__ name__)

@ app.route '/')
def main():
return render_template('main.html')

app.run(debug = True)


  app.run = False)

同时我也在寻找一种方法来在Windows上实际使用调试模式。 / p>

When running a basic Flask app I am getting this error in the shell and can't find how to solve this.

 Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) <br/>
 Restarting with stat<br/>
 Debugger is active!<br/>
 Debugger pin code: 295-257-376<br/>
Exception in thread Thread-1:<br/>
Traceback (most recent call last):<br/>
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35-32\lib\threading.py", line 923, in _bootstrap_inner
    self.run()<br/>
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35-32\lib\threading.py", line 871, in run
    self._target(*self._args, **self._kwargs) <br/>
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35-32\lib\site-packages\werkzeug\serving.py", line 656, in inner
    fd=fd)<br/>
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35-32\lib\site-packages\werkzeug\serving.py", line 550, in make_server
    passthrough_errors, ssl_context, fd=fd)<br/>
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35-32\lib\site-packages\werkzeug\serving.py", line 462, in __init__
    socket.SOCK_STREAM)<br/>
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python35-32\lib\socket.py", line 446, in fromfd
    nfd = dup(fd)<br/>
OSError: [WinError 10038] An operation was attempted on something that is not a socket

from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def main():
    return render_template('main.html')

app.run(debug=True)

解决方案

i know it is not a solution to the core problem, but for me the issue only occurs when setting the debug flag to True. If you can use your app without the debug/reloading features you might want to give it a try:

app.run(debug=False)

Meanwhile i am too searching for a way to actually use the debug mode on windows.

这篇关于在Windows上运行Flask应用程序会引发“尝试在不是套接字的东西上的操作”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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