Telethon is not working on pythonanywhere?

I want to make a request via telethon host on pythonanywhere.
I have 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 failed to Telegram {} 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?
April 19th 20 at 12:45
3 answers
April 19th 20 at 12:47
Solution
The problem was the host. Read more: help.pythonanywhere.com/pages/403ForbiddenError
I bought the subscription and it started to work.
April 19th 20 at 12:49
Write in BASH [Console] command: pip3.8 install --user telethon

YVYKZ8P.png
EqTb6fC.png
what does it mean for pythonaniwhere option -user? - chelsey_OKeefe58 commented on April 19th 20 at 12:52
@chelsey_OKeefe58, for a given user. - Gaetano.Skiles26 commented on April 19th 20 at 12:55
@Gaetano.Skiles26, Oh, now I wonder how in phytonadione to share the environment between the users of the resource. everyone has their own user ACC? - chelsey_OKeefe58 commented on April 19th 20 at 12:58
@chelsey_OKeefe58, right. But this is done not only because of the large number of users. On the website you can buy a subscription and use a lot of consoles in order to use Flask, another place VKAPI and so on, and not all in one heap. - Gaetano.Skiles26 commented on April 19th 20 at 13:01
I have already installed Telethon, even just in case rechecked, it has not changed, the error is the same as in the post. - Gladyce.Stracke commented on April 19th 20 at 13:04
@Gladyce.Stracke, a mistake is done in code. - Gaetano.Skiles26 commented on April 19th 20 at 13:07
@Gladyce.Stracke, try your code first to run on the computer, so it will be easier to check on the OVERALL efficiency of the code. - Gaetano.Skiles26 commented on April 19th 20 at 13:10
@Gaetano.Skiles26, I checked the code on your computer, there it works. The case in the host. - Gladyce.Stracke commented on April 19th 20 at 13:13
@Gladyce.Stracke, try to remove all WEB console directory and reinstall all over again. I once helped. - Gaetano.Skiles26 commented on April 19th 20 at 13:16
@Gaetano.Skiles26, And you used a Telethon on pythonanywhere, just maybe it's because of hosting restrictions, and I'm trying to do. If I have the free version, maybe depends on it? - Gladyce.Stracke commented on April 19th 20 at 13:19
April 19th 20 at 12:51
you need to install the telethon via pip, but this is not accurate. pietonniere many restrictions try heroku, it's not as complicated as it might seem at first glance a lot of pluses

Find more questions by tags TelegramPython