【发布时间】:2016-08-21 18:29:10
【问题描述】:
在运行基本的 Flask 应用程序时,我在 shell 中收到此错误并且找不到解决方法。
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)
【问题讨论】:
-
关闭防火墙后是否仍有错误(作为测试)?
-
关闭防火墙也没有用。错误同上。
-
好吧,其根本原因是它试图将文件句柄作为套接字打开,而 Windows 不支持。不过,它试图这样做似乎没有多大意义。
-
您是否以管理员用户身份运行此脚本?因为您的 Python 安装在 Admin 用户的帐户中
-
我尝试以管理员身份运行它,但没有成功。