thedemons / opentele

A Python Telegram API Library for converting between tdata and telethon sessions, with built-in official Telegram APIs.
https://opentele.readthedocs.io/
MIT License
264 stars 93 forks source link

No account has been loaded #79

Open AleksFimin opened 1 year ago

AleksFimin commented 1 year ago

Python version: 3.8.2 Pip version: 22.3.1 Operation System: Windows 10 (10.0.19044)

Tdata: Снимок экрана 2022-12-13 233245

Code:

from opentele.td import TDesktop
from opentele.tl import TelegramClient
from opentele.api import API, UseCurrentSession
import asyncio

async def main():

    # Load TDesktop client from tdata folder
    tdataFolder = r"C:\Users\Alex\Downloads\15\79872317223\tdata"
    tdesk = TDesktop(tdataFolder)

    # Check if we have loaded any accounts
    assert tdesk.isLoaded()

    # flag=UseCurrentSession
    #
    # Convert TDesktop to Telethon using the current session.
    client = await tdesk.ToTelethon(session="telethon.session", flag=UseCurrentSession)

    # Connect and print all logged-in sessions of this client.
    # Telethon will save the session to telethon.session on creation.
    await client.connect()
    await client.PrintSessions()

asyncio.run(main())

Error:

Traceback (most recent call last):
  File "test.py", line 63, in <module>
    asyncio.run(main())
  File "C:\Program Files\Python38\lib\asyncio\runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "test.py", line 48, in main
    tdesk = TDesktop(tdataFolder)
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 141, in __init__ 
    self.LoadTData()
PS D:\Code\Python\TgTool> py test.py
Traceback (most recent call last):
  File "test.py", line 25, in <module>
    asyncio.run(main())
  File "C:\Program Files\Python38\lib\asyncio\runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "test.py", line 10, in main
    tdesk = TDesktop(tdataFolder)
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 141, in __init__ 
    self.LoadTData()
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 216, in LoadTData
    raise e
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 203, in LoadTData
    self.__loadFromTData()
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 453, in __loadFromTData
    Expects(len(self.accounts) > 0, "No account has been loaded")
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\exception.py", line 326, in Expects
    raise exception
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 453, in __loadFromTData
    Expects(len(self.accounts) > 0, "No account has been loaded")
opentele.exception.OpenTeleException: Unexpected Exception: No account has been loaded [ Called by BaseObject.TDesktop.__loadFromTData() ]
Derivability commented 1 year ago

Same issue here Any updates on this?

gloriusglo commented 1 year ago

@AleksFimin, у меня получилось победить эту ошибку.

  1. https://github.com/thedemons/opentele/pull/74/files - пишут, что fix решает проблему, но я не стал его использовать. Удалил opentele и заново установил.
  2. В каталоге Tdata удалил все каталоги кроме D877F783D5D3EF8C, файлы все оставил.
  3. Из каталога D877F783D5D3EF8C удалил все, кроме файлов configs и maps.
  4. Скачал последнюю версию tportable с офсайта, открыл аккаунт в ней, вышел из программы.

После этого сессия создалась.

empty-git commented 1 year ago

Python version: 3.8.2 Pip version: 22.3.1 Operation System: Windows 10 (10.0.19044)

Tdata: Снимок экрана 2022-12-13 233245

Code:

from opentele.td import TDesktop
from opentele.tl import TelegramClient
from opentele.api import API, UseCurrentSession
import asyncio

async def main():

    # Load TDesktop client from tdata folder
    tdataFolder = r"C:\Users\Alex\Downloads\15\79872317223\tdata"
    tdesk = TDesktop(tdataFolder)

    # Check if we have loaded any accounts
    assert tdesk.isLoaded()

    # flag=UseCurrentSession
    #
    # Convert TDesktop to Telethon using the current session.
    client = await tdesk.ToTelethon(session="telethon.session", flag=UseCurrentSession)

    # Connect and print all logged-in sessions of this client.
    # Telethon will save the session to telethon.session on creation.
    await client.connect()
    await client.PrintSessions()

asyncio.run(main())

Error:

Traceback (most recent call last):
  File "test.py", line 63, in <module>
    asyncio.run(main())
  File "C:\Program Files\Python38\lib\asyncio\runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "test.py", line 48, in main
    tdesk = TDesktop(tdataFolder)
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 141, in __init__ 
    self.LoadTData()
PS D:\Code\Python\TgTool> py test.py
Traceback (most recent call last):
  File "test.py", line 25, in <module>
    asyncio.run(main())
  File "C:\Program Files\Python38\lib\asyncio\runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "test.py", line 10, in main
    tdesk = TDesktop(tdataFolder)
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 141, in __init__ 
    self.LoadTData()
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 216, in LoadTData
    raise e
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 203, in LoadTData
    self.__loadFromTData()
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 453, in __loadFromTData
    Expects(len(self.accounts) > 0, "No account has been loaded")
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\exception.py", line 326, in Expects
    raise exception
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 453, in __loadFromTData
    Expects(len(self.accounts) > 0, "No account has been loaded")
opentele.exception.OpenTeleException: Unexpected Exception: No account has been loaded [ Called by BaseObject.TDesktop.__loadFromTData() ]

Вам удалось найти фикс без костылей?

SharkLabDev commented 10 months ago

Same. How fix it? I tried as described above, but it didn’t work. There is a solution?

Kosminis commented 3 months ago

@AleksFimin, у меня получилось победить эту ошибку.

  1. https://github.com/thedemons/opentele/pull/74/files - пишут, что fix решает проблему, но я не стал его использовать. Удалил opentele и заново установил.
  2. В каталоге Tdata удалил все каталоги кроме D877F783D5D3EF8C, файлы все оставил.
  3. Из каталога D877F783D5D3EF8C удалил все, кроме файлов configs и maps.
  4. Скачал последнюю версию tportable с офсайта, открыл аккаунт в ней, вышел из программы.

После этого сессия создалась.

did not help. Any other solutions?

RobertAzovski commented 3 months ago

@AleksFimin, у меня получилось победить эту ошибку.

  1. https://github.com/thedemons/opentele/pull/74/files - пишут, что fix решает проблему, но я не стал его использовать. Удалил opentele и заново установил.
  2. В каталоге Tdata удалил все каталоги кроме D877F783D5D3EF8C, файлы все оставил.
  3. Из каталога D877F783D5D3EF8C удалил все, кроме файлов configs и maps.
  4. Скачал последнюю версию tportable с офсайта, открыл аккаунт в ней, вышел из программы.

После этого сессия создалась.

Didn't help with new tdatas

no-comm commented 3 months ago

as a temporary solution you can use the old version, I use tportable-x64.4.14.2, in it tdata is created exactly which is supported by the library

VectorASD commented 3 months ago

One reason may be that the teleopen is out of date. I have the last entry in my keycard for key type 25, which is probably 16 bytes long. If this entry is ignored, this error does not occur ;'-} BugReport: https://github.com/thedemons/opentele/issues/120

KEKACIK commented 2 months ago

Hello everyone, today I found a solution to this error. It occurs due to the fact that we are creating tdata from a new version of the telegram client, and the last update of the opentele library was 2 years ago. SOLUTION We go to the official git opentele (link below) and download the latest version, released 7 months ago and run it locally. https://github.com/thedemons/opentele

Thank you all for your attention <3

SamVitas1983 commented 1 month ago

Hello everyone, today I found a solution to this error. It occurs due to the fact that we are creating tdata from a new version of the telegram client, and the last update of the opentele library was 2 years ago. SOLUTION We go to the official git opentele (link below) and download the latest version, released 7 months ago and run it locally. https://github.com/thedemons/opentele

Thank you all for your attention <3

Works for me, great job bro!

adist commented 1 month ago

Hello everyone, today I found a solution to this error. It occurs due to the fact that we are creating tdata from a new version of the telegram client, and the last update of the opentele library was 2 years ago. SOLUTION We go to the official git opentele (link below) and download the latest version, released 7 months ago and run it locally. https://github.com/thedemons/opentele Thank you all for your attention <3

Works for me, great job bro!

Hi Sam.. may i know which python version you use?

because i still got that error on Python 3.7, pip 24.0, on Windows 11..

SamVitas1983 commented 1 month ago

Hello everyone, today I found a solution to this error. It occurs due to the fact that we are creating tdata from a new version of the telegram client, and the last update of the opentele library was 2 years ago. SOLUTION We go to the official git opentele (link below) and download the latest version, released 7 months ago and run it locally. https://github.com/thedemons/opentele Thank you all for your attention <3

Works for me, great job bro!

Hi Sam.. may i know which python version you use?

because i still got that error on Python 3.7, pip 24.0, on Windows 11..

I'm using Python 3.11. Have you copy the latest SCR files into C:\Program Files\Python\Lib\site-packages\opentele ? Good luck