Installation¶
Automatic Installation¶
To install Telethon, simply do:
pip3 install telethon
Needless to say, you must have Python 3 and PyPi installed in your system. See https://python.org and https://pypi.python.org/pypi/pip for more.
If you already have the library installed, upgrade with:
pip3 install --upgrade telethon
You can also install the library directly from GitHub or a fork:
# pip3 install git+https://github.com/LonamiWebs/Telethon.git
or
$ git clone https://github.com/LonamiWebs/Telethon.git
$ cd Telethon/
# pip install -Ue .
If you don’t have root access, simply pass the --user
flag to the pip
command. If you want to install a specific branch, append @branch
to
the end of the first install command.
By default the library will use a pure Python implementation for encryption,
which can be really slow when uploading or downloading files. If you don’t
mind using a C extension, install cryptg
via pip
or as an extra:
pip3 install telethon[cryptg]
Manual Installation¶
Install the required
pyaes
(GitHub | PyPi) andrsa
(GitHub | PyPi) modules:pip3 install pyaes rsa
Clone Telethon’s GitHub repository:
git clone https://github.com/LonamiWebs/Telethon.git
Enter the cloned repository:
cd Telethon
Run the code generator:
python3 setup.py gen
Done!
To generate the method documentation, python3 setup.py gen docs
.
Optional dependencies¶
If pillow is installed, large images will be automatically resized when sending photos to prevent Telegram from failing with “invalid image”. Official clients also do this.
If aiohttp is installed, the library will be able to download WebDocument media files (otherwise you will get an error).
If hachoir is installed, it will be used to extract metadata from files when sending documents. Telegram uses this information to show the song’s performer, artist, title, duration, and for videos too (including size). Otherwise, they will default to empty values, and you can set the attributes manually.
If cryptg is installed, encryption and decryption will be made in C instead of Python which will be a lot faster. If your code deals with a lot of updates or you are downloading/uploading a lot of files, you will notice a considerable speed-up (from a hundred kilobytes per second to several megabytes per second, if your connection allows it). If it’s not installed, pyaes will be used (which is pure Python, so it’s much slower).