嘿,我在试着编辑一个电报机器人,但是这个错误不断出现:import telegram.ext ModuleNotFoundError: No module named 'telegram.ext'; 'telegram' is not a package
。
我的代码是这样的:
import telegram.ext
with open('token.txt', 'r') as f:
TOKEN = f.read()
def start(update, context):
update.message.reply_text("Helllo")
updater = telegram.ext.Updater(TOKEN, use_context=True)
disp = updater.dispatcher
如有任何帮助,将不胜感激。
我试过重新安装python-电报-bot。
发布于 2022-11-01 07:43:31
可能你也安装了一个错误的电报包。有些IDE自动安装软件包,并安装电报而不是python-电报-bot。
您应该找到错误的安装包并卸载它。
找出在import telegram.ext
上导入的包,您可以在错误描述中找到它。然后使用如下命令卸载它:
pip uninstall telegam
如果没有安装python-telegram-bot
,则安装它:
pip install python-telegram-bot
https://stackoverflow.com/questions/74254093
复制相似问题