2017-11-20 07:12:31 +03:00
|
|
|
.. _installation:
|
|
|
|
|
2018-01-05 02:59:53 +03:00
|
|
|
============
|
2017-11-20 07:12:31 +03:00
|
|
|
Installation
|
2018-01-05 02:59:53 +03:00
|
|
|
============
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-10-06 21:20:11 +03:00
|
|
|
.. contents::
|
|
|
|
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
Automatic Installation
|
2018-01-05 02:59:53 +03:00
|
|
|
**********************
|
|
|
|
|
2017-11-20 07:12:31 +03:00
|
|
|
To install Telethon, simply do:
|
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: sh
|
|
|
|
|
|
|
|
pip3 install telethon
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-01-12 12:08:40 +03:00
|
|
|
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.
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
If you already have the library installed, upgrade with:
|
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: sh
|
|
|
|
|
|
|
|
pip3 install --upgrade telethon
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
You can also install the library directly from GitHub or a fork:
|
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: sh
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
# pip3 install git+https://github.com/LonamiWebs/Telethon.git
|
|
|
|
or
|
|
|
|
$ git clone https://github.com/LonamiWebs/Telethon.git
|
|
|
|
$ cd Telethon/
|
|
|
|
# pip install -Ue .
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-01-20 13:47:17 +03:00
|
|
|
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.
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-02-17 14:14:23 +03:00
|
|
|
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 <https://github.com/Lonami/cryptg>`__
|
|
|
|
via ``pip`` or as an extra:
|
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: sh
|
|
|
|
|
|
|
|
pip3 install telethon[cryptg]
|
2018-02-17 14:14:23 +03:00
|
|
|
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
Manual Installation
|
2018-01-05 02:59:53 +03:00
|
|
|
*******************
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-01-05 02:59:53 +03:00
|
|
|
1. Install the required ``pyaes`` (`GitHub`__ | `PyPi`__) and
|
|
|
|
``rsa`` (`GitHub`__ | `PyPi`__) modules:
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: sh
|
|
|
|
|
|
|
|
pip3 install pyaes rsa
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-01-05 02:59:53 +03:00
|
|
|
2. Clone Telethon's GitHub repository:
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: sh
|
|
|
|
|
|
|
|
git clone https://github.com/LonamiWebs/Telethon.git
|
|
|
|
|
|
|
|
3. Enter the cloned repository:
|
|
|
|
|
|
|
|
.. code-block:: sh
|
|
|
|
|
|
|
|
cd Telethon
|
|
|
|
|
|
|
|
4. Run the code generator:
|
|
|
|
|
|
|
|
.. code-block:: sh
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
python3 setup.py gen
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
5. Done!
|
|
|
|
|
2018-05-30 19:55:01 +03:00
|
|
|
To generate the `method documentation`__, ``python3 setup.py gen docs``.
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
Optional dependencies
|
2018-01-05 02:59:53 +03:00
|
|
|
*********************
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2019-03-21 18:55:32 +03:00
|
|
|
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
|
|
|
|
:tl:`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).
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
__ https://github.com/ricmoo/pyaes
|
|
|
|
__ https://pypi.python.org/pypi/pyaes
|
2018-01-20 13:47:17 +03:00
|
|
|
__ https://github.com/sybrenstuvel/python-rsa
|
2017-11-20 07:12:31 +03:00
|
|
|
__ https://pypi.python.org/pypi/rsa/3.4.2
|
2018-01-20 13:47:17 +03:00
|
|
|
__ https://lonamiwebs.github.io/Telethon
|
2019-03-21 18:55:32 +03:00
|
|
|
|
|
|
|
.. _pillow: https://python-pillow.org
|
|
|
|
.. _aiohttp: https://docs.aiohttp.org
|
|
|
|
.. _hachoir: https://hachoir.readthedocs.io
|
|
|
|
.. _cryptg: https://github.com/Lonami/cryptg
|
|
|
|
.. _pyaes: https://github.com/ricmoo/pyaes
|