@kot123123
я кот

Как исправить ошибку py3?

есть программа, сразу говорю я ее скопипастил, с целью ознакомления вот она:
from vk_api.longpoll import VkLongPoll, VkEventType
import vk_api
from datetime import datetime

login, password = "мой логин", "пароль"
vk_session = vk_api.VkApi(login=login, password=password, app_id=2685278)
vk_session.auth(token_only=True)

token = "токен"
vk_session = vk_api.VkApi(token=token)

session_api = vk_session.get_api()
longpoll = VkLongPoll(vk_session)
#While True здесь оказался не нужен. Его функцию выполняет for event in longpoll.listen(): Спасибо подписчику за это уточнение.

for event in longpoll.listen():
    if event.type == VkEventType.MESSAGE_NEW:
        print('Сообщение пришло в: ' + str(datetime.strftime(datetime.now(), "%H:%M:%S")))
        print('Текст сообщения: ' + str(event.text))


при запуске через консоль я получаю вот это:
from: can't read /var/mail/vk_api.longpoll
import-im6.q16: not authorized `vk_api' @ error/constitute.c/WriteImage/1037.
from: can't read /var/mail/datetime
./vkBot.py: 5: ./vkBot.py: login,: not found
./vkBot.py: 6: ./vkBot.py: Syntax error: "(" unexpected

изменено:
Я понял, что у меня не установлена эта либа и мне ее надо установить, но при установке pip выдает ошибки
эта если без рута запускать
The directory '/home/kokos/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/kokos/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting vk_api
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 342, in run
    requirement_set.prepare_files(finder)
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 281, in populate_link
    self.link = self._wheel_cache.cached_wheel(self.link, self.name)
  File "/usr/lib/python3/dist-packages/pip/wheel.py", line 68, in cached_wheel
    self._cache_dir, link, self._format_control, package_name)
  File "/usr/lib/python3/dist-packages/pip/wheel.py", line 129, in cached_wheel
    wheel_names = os.listdir(root)
PermissionError: [Errno 13] Отказано в доступе: '/home/kokos/.cache/pip/wheels/39/bb/05/c3d370a1097f993c1089e0c6265f7cb782b4a583110f747805'

А эта от рута
Requirement already satisfied: vk_api in /home/kokos/.local/lib/python3.6/site-packages
Requirement already satisfied: requests in /home/kokos/.local/lib/python3.6/site-packages (from vk_api)
Requirement already satisfied: six in /home/kokos/.local/lib/python3.6/site-packages (from vk_api)
Requirement already satisfied: idna<3,>=2.5 in /home/kokos/.local/lib/python3.6/site-packages (from requests->vk_api)
Requirement already satisfied: certifi>=2017.4.17 in /home/kokos/.local/lib/python3.6/site-packages (from requests->vk_api)
Requirement already satisfied: chardet<4,>=3.0.2 in /home/kokos/.local/lib/python3.6/site-packages (from requests->vk_api)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /home/kokos/.local/lib/python3.6/site-packages (from requests->vk_api)
  • Вопрос задан
  • 133 просмотра
Пригласить эксперта
Ответы на вопрос 1
@Bogdan2033
Syntax error: "(" unexpected - проверь это место, видимо скобка не стоит.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы