无法导入电视节目

Cannot import telethon

有电视节目使用我的代码。 出于某种原因,我的代码在一段时间后不再工作,所以尝试升级 telethon 库。现在连telethon都导入不了

按照此处的安装说明进行操作:https://telethon.readthedocs.io/en/latest/basic/installation.html

# pip3 show telethon

Name: Telethon
Version: 1.8.0
Summary: Full-featured Telegram client library for Python 3
Home-page: https://github.com/LonamiWebs/Telethon
Author: Lonami Exo
Author-email: totufals@hotmail.com
License: MIT
Location: /home/XXX/.local/lib/python3.5/site-packages
Requires: pyaes, rsa
Required-by: 

在此之后,尝试对 telethon 库进行基本导入失败。 运行 python 3.5.2

# python3 -c "import telethon;"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/xxx/.local/lib/python3.5/site-packages/telethon/__init__.py", line 1, in <module>
    from .client.telegramclient import TelegramClient
  File "/home/xxx/.local/lib/python3.5/site-packages/telethon/client/__init__.py", line 13, in <module>
    from .users import UserMethods  # Required for everything
  File "/home/xxx/.local/lib/python3.5/site-packages/telethon/client/users.py", line 7, in <module>
    from .. import errors, utils, hints
  File "/home/xxx/.local/lib/python3.5/site-packages/telethon/hints.py", line 56, in <module>
    typing.BinaryIO
  File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "/usr/lib/python3.5/typing.py", line 512, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 1077, in __subclasscheck__
    if super().__subclasscheck__(cls):
  File "/usr/lib/python3.5/abc.py", line 225, in __subclasscheck__
    for scls in cls.__subclasses__():
TypeError: descriptor '__subclasses__' of 'type' object needs an argument

这是您正在使用的 python 版本中的错误(参见 https://github.com/python/typing/issues/266); and it's also an open issue in Telethon repo (see https://github.com/LonamiWebs/Telethon/issues/1177)。

将您的 python 升级到最新版本,问题就会消失。