python flask 进程问题
运行:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
报错:
* Serving Flask app "t" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Traceback (most recent call last):
File "t.py", line 8, in <module>
app.run()
File "/home/xiaohe/.local/lib/python3.7/site-packages/flask/app.py", line 990, in run
run_simple(host, port, self, **options)
File "/home/xiaohe/.local/lib/python3.7/site-packages/werkzeug/serving.py", line 1010, in run_simple
inner()
File "/home/xiaohe/.local/lib/python3.7/site-packages/werkzeug/serving.py", line 963, in inner
fd=fd,
File "/home/xiaohe/.local/lib/python3.7/site-packages/werkzeug/serving.py", line 806, in make_server
host, port, app, request_handler, passthrough_errors, ssl_context, fd=fd
File "/home/xiaohe/.local/lib/python3.7/site-packages/werkzeug/serving.py", line 699, in __init__
HTTPServer.__init__(self, server_address, handler)
File "/home/xiaohe/anaconda3/lib/python3.7/socketserver.py", line 452, in __init__
self.server_bind()
File "/home/xiaohe/anaconda3/lib/python3.7/http/server.py", line 137, in server_bind
socketserver.TCPServer.server_bind(self)
File "/home/xiaohe/anaconda3/lib/python3.7/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
解决方案:
$ ps -fA | grep python
henry 127112 1181 0 12:07 ? 00:00:05 /usr/bin/python /usr/bin/x-terminal-emulator
henry 127201 124727 0 12:09 ? 00:00:01 python3 -u /home/henry/dev/myproject/flaskr/flaskr.py
henry 127252 127122 0 12:20 pts/4 00:00:00 grep --color=auto python
$ kill 127201
————————————————
注意:关键问题: 杀死占用的进程
查看: ps -fA | grep python
杀死:kill 号
版权声明:本文为优快云博主「HenryQWER」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/qq_33528613/article/details/78631036