我的代码非常简单:
from flask import Flask
app = Flask(__name__)
if __name__ == '__main__':
app.run(debug=True)
我第一次运行它并且它运行了,然后ctrl + c没有工作所以我自己就杀了python终端。然后我试着再次运行它,我收到一个错误:
* Serving Flask app "untitled1" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production
environment.
Use a production WSGI server instead.
* Debug mode: on
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-
packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699,
in runfile
execfile(filename, namespace)
File "/usr/lib/python3/dist-
packages/spyderlib/widgets/externalshell/sitecustomize.py", line 88,
in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'),
namespace)
File "/home/teoman/Desktop/flaskapp/untitled1.py", line 13, in
<module>
app.run(debug=True)
File "/home/teoman/.local/lib/python3.5/site-packages/flask/app.py",
line 943, in run
run_simple(host, port, self, **options)
File "/home/teoman/.local/lib/python3.5/site-
packages/werkzeug/serving.py", line 795, in run_simple
s.bind(get_sockaddr(hostname, port, address_family))
OSError: [Errno 98] Address already in use
我发现了类似的问题,但我无法理解,因为解决方案也很复杂,我对Flask app很新(比如十分钟),我使用Linux Mint MATE。
注意:localhost:5000工作正常我仍然没有任何python命令行打开工作Flask应用程序。
答案 0 :(得分:3)