gpt4 book ai didi

python - 如何避免 Web 框架 Bottle 中已使用的端口错误?

转载 作者:行者123 更新时间:2023-12-01 09:32:58 25 4
gpt4 key购买 nike

在Python3中我有一个程序来测试Web框架 Bottle :

from bottle import route, run

@route('/')
def index():
return "olá pessoas"

if __name__ == '__main__':
run()

我正在 virtualenv 中的命令行中运行程序。但出现这个错误:

(live-de-python) reinaldo@reinaldo-Inspiron-5567:~/Documentos/Code/live-de-python/repo$ python3 basic_bottle.py
Bottle v0.12.13 server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.

Traceback (most recent call last):
File "basic_bottle.py", line 11, in <module>
run()
File "/home/reinaldo/Documentos/Code/live-de-python/lib/python3.6/site-packages/bottle.py", line 3127, in run
server.run(app)
File "/home/reinaldo/Documentos/Code/live-de-python/lib/python3.6/site-packages/bottle.py", line 2781, in run
srv = make_server(self.host, self.port, app, server_cls, handler_cls)
File "/usr/lib/python3.6/wsgiref/simple_server.py", line 153, in make_server
server = server_class((host, port), handler_class)
File "/usr/lib/python3.6/socketserver.py", line 453, in __init__
self.server_bind()
File "/usr/lib/python3.6/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.6/http/server.py", line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.6/socketserver.py", line 467, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

我正在使用Ubuntu。错误是否表明端口 8080 已被使用?但我没有打开其他程序

请问有人知道这是什么吗?

最佳答案

端口 8080 已被其他进程使用。您可能启动了脚本但忘记结束它。检查

$ ps -aux | grep basic_bottle

或者只需使用 run(port=8090) 更改端口。

关于python - 如何避免 Web 框架 Bottle 中已使用的端口错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49793220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com