Answer the question
In order to leave comments, you need to log in
VKApi AttributeError: module 'vk_api' has no attribute 'VKApi' how to solve?
AttributeError: module 'vk_api' has no attribute 'VKApi' Throws
when running this code...
I've been trying to figure out what's wrong for 3 hours now
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
from toks import main_token
vk = vk_session.get_api()
vk_session = vk_api.VKApi(token = main_token )
session_api = vk.session.get_api()
longpoll = VklongPoll(vk_session)
def sender(id, text):
vk_session.method('message.send', {"user_id" : id, 'message' : text, 'random id' : 0})
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.to_me:
msg = events.text.lower()
id = event .user_id
if msg == "xxxx":
sender(id, 'xxx')
Answer the question
In order to leave comments, you need to log in
Fix vk_session = vk_api.VKApi(token = main_token ) , to vk_session = vk_api.VkApi(token = main_token )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question