ImportError from aiogram

hi, i encountered a problem when running the script using aiogram

the script:

from aiogram import Bot, Dispatcher, executor, types

bot = Bot(token=‘BOT_TOKEN’)
dp = Dispatcher(bot)

@dp.message_handler(commands=[‘start’, ‘help’])
async def welcome(message: types.Message):
await message.reply(“Hello! Welcome to Attendance Bot!”)

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

executor.start_polling(dp)

it shows ImportError: cannot import name ‘executor’ from ‘aiogram’

try this
from aiogram import Bot, Dispatcher, types
from aiogram.utils import executor

bot = Bot(token=‘BOT_TOKEN’)
dp = Dispatcher(bot)

@dp.message_handler(commands=[‘start’, ‘help’])
async def welcome(message: types.Message):
await message.reply(“Hello! Welcome to Attendance Bot!”)

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

if name == ‘main’:
executor.start_polling(dp, skip_updates=True)

1 Like

@kokomonster98 can you tell me which project you are trying to build?

Hi @kokomonster98

You can check this thread: Error white creating a telegram bot - #10 by sneharsh.kerkar