导入 InputPeerChannel 时出现 Telethon 错误
Telethon error when import InputPeerChannel
我刚开始学习python。现在我正在为 Telegram 做一个机器人。为了使用 Core API,我使用 Telethon 库 Python 3。错误发生在行中:
from telethon.utils import InputPeerChannel
错误文本:
Traceback (most recent call last):
File "F:\Work\Projects\Python\Bots\NewsBot\main.py", line 5, in <module>
from telethon.utils import InputPeerChannel
ImportError: cannot import name 'InputPeerChannel' from 'telethon.utils' (F:\Work\Projects\Python\Bots\NewsBot\venv\lib\site-packages\telethon\utils.py)
- 版本电视节目 1.24.0
- Python 3.9
- IDE PyCharm
python 中的 ImportError
表示名称(在本例中为 InputPeerChannel
)不在模块中(在本例中为 telethon.utils
)或者找不到模块。
在你的情况下,第一个发生,模块 telethon.utils
存在但它不包含名称 InputPeerChannel
。该名称可以在模块 tlethon.tl.types
中找到,因此您可以从那里导入它。
>>> from telethon.tl.types import InputPeerChannel
我刚开始学习python。现在我正在为 Telegram 做一个机器人。为了使用 Core API,我使用 Telethon 库 Python 3。错误发生在行中:
from telethon.utils import InputPeerChannel
错误文本:
Traceback (most recent call last):
File "F:\Work\Projects\Python\Bots\NewsBot\main.py", line 5, in <module>
from telethon.utils import InputPeerChannel
ImportError: cannot import name 'InputPeerChannel' from 'telethon.utils' (F:\Work\Projects\Python\Bots\NewsBot\venv\lib\site-packages\telethon\utils.py)
- 版本电视节目 1.24.0
- Python 3.9
- IDE PyCharm
python 中的 ImportError
表示名称(在本例中为 InputPeerChannel
)不在模块中(在本例中为 telethon.utils
)或者找不到模块。
在你的情况下,第一个发生,模块 telethon.utils
存在但它不包含名称 InputPeerChannel
。该名称可以在模块 tlethon.tl.types
中找到,因此您可以从那里导入它。
>>> from telethon.tl.types import InputPeerChannel