M
M
MaxKovalunas2020-09-14 12:13:59
Python
MaxKovalunas, 2020-09-14 12:13:59

How to solve the problem with starting the Bot with the aiogram library?

Hello. Wrote the following test bot on aiogram:

import logging
from aiogram import Bot, Dispatcher, executor, types

API_TOKEN ='Указан мой токен'
logging.basicConfig(level=logging.INFO)

bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)

@dp.message_handler(commands =['start, help'])
async def send_welcome(message: types.Message):

  await message.reply("hi\nI'm aiobot..")

@dp.message_handler()
async def echo(message: types.Message):
  
  await message.answer(message.text)

if __name__ == '__main__':
  executor.start_polling(dp, skip_updates=True)


And when I run it I get the following error:

C:\AIOGRAM\myles>python bot.py
Traceback (most recent call last):
File "C:\Users\maxim\AppData\Local\Programs\Python\Python38-32\lib\site -packages\aiogram\utils\executor.py", line 305, in start_polling
loop.run_until_complete(self._startup_polling())
AttributeError: 'NoneType' object has no attribute 'run_until_complete'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "bot.py", line 33, in
executor.start_polling(dp, skip_updates=True)
File "C:\Users\maxim\AppData\Local\Programs\Python\Python38-32\ lib\site-packages\aiogram\utils\executor.py", line 41,in start_polling
executor.start_polling(reset_webhook=reset_webhook, timeout=timeout, relax=relax, fast=fast)
File "C:\Users\maxim\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\utils \executor.py", line 313, in start_polling
loop.run_until_complete(self._shutdown_polling())
AttributeError: 'NoneType' object has no attribute 'run_until_complete' This is the

first time I've encountered this. Previously, bots were launched, both on aiogram and on pytelegrambotapi.
How many I searched for the answer - nowhere even close did not find similar situations. The bot was launched both on the local machine and on the server - the error is the same.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MaxKovalunas, 2020-09-14
@MaxKovalunas

On an older version of aiogram, everything works. Looks like an update issue.

D
DmitriyPopovich, 2020-09-29
@DmitriyPopovich

faced a similar problem
Above in the comment is true, aiogram 2.10 produces such errors Solved
by removing 2.10 and installing 2.9

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question