eternnoir / pyTelegramBotAPI

Python Telegram bot api.
GNU General Public License v2.0
8.12k stars 2.03k forks source link

Can't use send_document method #1982

Closed AdonayVeiga closed 1 year ago

AdonayVeiga commented 1 year ago
  1. What version of pyTelegramBotAPI are you using? 4.11.0

  2. What OS are you using? Windows

  3. What version of python are you using? 3.9.4

Documentation says to use telebot.types.InputFile to upload a new file, but when I try to run provided example I get an "ImportError: cannot import name 'InputFile' from 'telebot.types'"

Am I doing it wrong? Documentation need update? Thanks in advance

AdonayVeiga commented 1 year ago

I also tried to

from telebot import types send_document(message.chat.id, types.InputFile('path\to\file'))

but then I got an "AttributeError: module 'telebot.types' has no attribute 'InputFile'"

Badiboy commented 1 year ago

See the working example.

https://pytba.readthedocs.io/en/latest/types.html#telebot.types.InputFile

coder2020official commented 1 year ago

Are you sure you don't have wrong library(telebot) installed?

AdonayVeiga commented 1 year ago

See the working example.

https://pytba.readthedocs.io/en/latest/types.html#telebot.types.InputFile

That is exactly the same example i'm try to run. Please check the link under telebot.types.InputFile in the first comment.

Are you sure you don't have wrong library(telebot) installed?

I'm pretty sure. I've installed library with pip install pyTelegramBotAPI and here is the pip freeze output:

certifi==2022.12.7 charset-normalizer==3.1.0 idna==3.4 numpy==1.24.3 pandas==2.0.1 pyTelegramBotAPI==4.11.0 python-dateutil==2.8.2 pytz==2023.3 requests==2.30.0 six==1.16.0 tzdata==2023.3 urllib3==2.0.2

AdonayVeiga commented 1 year ago

I found what was wrong. I actually have an issue with my virtual enviroment. Sorry and thanks.