C
C
che_aa2020-04-18 21:37:23
Python
che_aa, 2020-04-18 21:37:23

telethon not working on pythonanywhere?

I want to make a request via telethon to a pythonanywhere host.
Gives me an error:

Traceback (most recent call last):
File "/home/me/text.py", line 13, in
client.start()
File "/home/me/.local/lib/python3.7/site-packages/telethon /client/auth.py", line 132, in start
else self.loop.run_until_complete(coro)
Traceback (most recent call last):
File "/home/me/text.py", line 15, in
client.start( )
File "/home/me/.local/lib/python3.7/site-packages/telethon/client/auth.py", line 132, in start
else self.loop.run_until_complete(coro)
File "/usr/lib /python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "/home/me/.local/lib/python3.7/site-packages/telethon/client/auth.py ",line 139, in_start
await self.connect()
File "/home/me/.local/lib/python3.7/site-packages/telethon/client/telegrambaseclient.py", line 445, in connect
proxy=self._proxy
File "/home/ me/.local/lib/python3.7/site-packages/telethon/network/mtprotosender.py", line 125, in connect
await self._connect()
File "/home/me/.local/lib/python3.7 /site-packages/telethon/network/mtprotosender.py", line 250, in _connect
raise ConnectionError('Connection to Telegram failed {} time(s)'.format(self._retries))
ConnectionError: Connection to Telegram failed 5 time (s)

the code itself:
from telethon import TelegramClient, sync, functions
from telethon.tl.functions.messages import ImportChatInviteRequest
from telethon import connection

api_id = '**'
api_hash = '**'
client = TelegramClient('test', api_id, api_hash)
client.start()

username = client.get_entity('user')
print(username)

How can this be fixed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
che_aa, 2020-04-19
@che_aa

The problem was in the host. Read more: help.pythonanywhere.com/pages/403ForbiddenError
I bought a subscription and everything started working.

N
Nikita Stupnikov, 2020-04-18
@JobJobBoy

Write in BASH [Console] command: pip3.8 install --user telethon
YVYKZ8P.png
EqTb6fC.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question