Discuss / Python / python3.6.3直接报错啊,萌比ing

python3.6.3直接报错啊,萌比ing

Topic source

风逝紫玄

#1 Created at ... [Delete] [Delete and Lock User]
"""
async web application.
"""
import asyncio
import logging

from aiohttp import web

logging.basicConfig(level=logging.INFO)


def index():
    return web.Response(body=b'<h1>Mystic</h1>')


async def init(loop_):
    app = web.Application(loop=loop_)
    app.router.add_route('GET', '/', index)
    server = await loop_.create_server(app.make_handler(), '127.0.0.1', 9000)
    logging.info('Server started at http://127.0.0.1:9000...')
    return server


loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
loop.run_forever()

风逝紫玄

#2 Created at ... [Delete] [Delete and Lock User]
"D:\Program Files\Python36\python.exe" D:/JetBrains/PycharmProjects/Blog_Python/www/app.py
Traceback (most recent call last):
  File "D:\Program Files\Python36\lib\asyncio\base_events.py", line 1044, in create_server
    sock.bind(sa)
OSError: [WinError 10048] 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/JetBrains/PycharmProjects/Blog_Python/www/app.py", line 30, in <module>
    loop.run_until_complete(init(loop))
  File "D:\Program Files\Python36\lib\asyncio\base_events.py", line 467, in run_until_complete
    return future.result()
  File "D:/JetBrains/PycharmProjects/Blog_Python/www/app.py", line 24, in init
    server = await loop_.create_server(app.make_handler(), '127.0.0.1', 9000)
  File "D:\Program Files\Python36\lib\asyncio\base_events.py", line 1048, in create_server
    % (sa, err.strerror.lower()))
OSError: [Errno 10048] error while attempting to bind on address ('127.0.0.1', 9000): 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。

Process finished with exit code 1

风逝紫玄

#3 Created at ... [Delete] [Delete and Lock User]

可以了.........今天的我和昨天的我,有什么区别的?昨天request不管加不加,都会报错,今天加个request就不报错了.......

你的错误是端口被占用了,要是还出现那种错误,换个端口就行了,比如换成9001

我也是报这个错误,根据你说的修改端口号,也不能行; 然后显示是这样的。 D:\learning\python\python.exe E:/awesome-python3-webapp/www/static/app.py INFO:root:server started at http://127.0.0.1:9005...


  • 1

Reply