OSError: [Errno 98] Address already in use

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 号

版权声明:本文为CSDN博主「HenryQWER」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_33528613/article/details/78631036

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值