Перейти к содержимому

Pip install telethon как установить

  • автор:

Installation¶

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¶

  1. Install the required pyaes (GitHub | PyPi) and rsa (GitHub | PyPi) modules:
pip3 install pyaes rsa
git clone https://github.com/LonamiWebs/Telethon.git
cd Telethon
python3 setup.py gen

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).

© Copyright 2017, Lonami Revision 744f5f50 .

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: stable

Versions latest stable Downloads On Read the Docs Project Home Builds Free document hosting provided by Read the Docs.

Installation¶

Telethon is a Python library, which means you need to download and install Python from https://www.python.org/downloads/ if you haven’t already. Once you have Python installed, upgrade pip and run:

python3 -m pip install --upgrade pip python3 -m pip install --upgrade telethon

…to install or upgrade the library to the latest version.

Installing Development Versions¶

If you want the latest unreleased changes, you can run the following command instead:

python3 -m pip install --upgrade https://github.com/LonamiWebs/Telethon/archive/v1.zip

The development version may have bugs and is not recommended for production use. However, when you are reporting a library bug, you should try if the bug still occurs in this version.

Verification¶

To verify that the library is installed correctly, run the following command:

python3 -c "import telethon; print(telethon.__version__)" 

The version number of the library should show in the output.

Optional Dependencies¶

If cryptg is installed, the library will work a lot faster, since encryption and decryption will be made in C instead of Python. 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).

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.

Some of the modules may require additional dependencies before being installed through pip . If you have an apt -based system, consider installing the most commonly missing dependencies (with the right pip ):

apt update apt install clang libjpeg-turbo,webp>-dev python,-dev> zlib-dev pip install -U --user setuptools pip install -U --user telethon cryptg pillow

Thanks to @bb010g for writing down this nice list.

© Copyright 2017 — 2019, Lonami Revision 7325718f .

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: stable

Versions stable Downloads pdf html epub On Read the Docs Project Home Builds Free document hosting provided by Read the Docs.

Как установить модуль в Python?

Устанавливаю модуль telethon в питон. В командной строке прописал «pip install telethon», модуль загрузился, все вроде ок, но при импортировании модуля в код выдает ошибку: Traceback (most recent call last):
File «main.py», line 4, in
from telethon import TelegramClient
ImportError: No module named ‘telethon’

а если перед всем кодом написать «pip install telethon» выдает:
File «main.py», line 1
pip install telethon
^
SyntaxError: invalid syntax

Как это можно исправить и что мне необходимо сделать для того чтобы telethon нормально работал?

  • Вопрос задан более трёх лет назад
  • 3013 просмотров

2 комментария

Простой 2 комментария

Telethon 1.33.1

⭐️ Thanks everyone who has starred the project, it means a lot!

Telethon is an asyncio Python 3 MTProto library to interact with Telegram’s API as a user or through a bot account (bot API alternative).

If you have code using Telethon before its 1.0 version, you must read Compatibility and Convenience to learn how to migrate. As with any third-party library for Telegram, be careful not to break Telegram’s ToS or Telegram can ban the account.

What is this?

Telegram is a popular messaging application. This library is meant to make it easy for you to write Python programs that can interact with Telegram. Think of it as a wrapper that has already done the heavy job for you, so you can focus on developing an application.

Installing

pip3 install telethon

Creating a client

Doing stuff

Next steps

Do you like how Telethon looks? Check out Read The Docs for a more in-depth explanation, with examples, troubleshooting issues, and more useful information.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *