如何安装python-telegram-bot版本20及更高版本

发布于 2025-02-01 20:43:39 字数 741 浏览 4 评论 0原文

尝试从官方网站运行示例或电报机器人 - https ://github.com/python-telegram-bot/python-telegram-bot/tree/master/master/examples 已安装:

pip install python-telegram-bot

当我运行示例时,我收到了错误,该版本不兼容。

if __version_info__ < (20, 0, 0, "alpha", 1):
    raise RuntimeError(
        f"This example is not compatible with your current PTB version {TG_VER}. To view the "
        f"{TG_VER} version of this example, "
        f"visit https://github.com/python-telegram-bot/python-telegram-bot/tree/v{TG_VER}/examples"
    )

它安装了PYPI版本13.12,但示例检查了不同版本V20。因此,错误是合理的。 我如何让榜样工作?

Trying to run examples or telegram bots from official site - https://github.com/python-telegram-bot/python-telegram-bot/tree/master/examples
Installed :

pip install python-telegram-bot

and when i run the example, i got error back that version is not compatible.

if __version_info__ < (20, 0, 0, "alpha", 1):
    raise RuntimeError(
        f"This example is not compatible with your current PTB version {TG_VER}. To view the "
        f"{TG_VER} version of this example, "
        f"visit https://github.com/python-telegram-bot/python-telegram-bot/tree/v{TG_VER}/examples"
    )

It installs PyPi version 13.12 but example checks different version v20. So, the error is reasonable.
How can I let example working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖上得阳光 2025-02-08 20:43:39

可能您正在使用v20.0版本中的示例,将标签更改为v13.12

Probably you are using examples from v20.0 version, change the tag to v13.12
enter image description here

春风十里 2025-02-08 20:43:39

对我感到羞耻,我花了几天时间得到答案 - 20倍仅是预发行版本!要找到明确的解释,您必须阅读Wiki,甚至不在首页上 - https://github.com/python-telegram-bot/python-telegram-bot/wiki/wiki/introduction-to-to-the-api
这是具有20倍状态和正确安装过程的清晰答案的唯一信息来源。
因此,这是过程 - pip install python -telegram -bot -u -pre -pre
顺便说一句,您必须检查是否也安装了“电报”软件包。首先卸载它,然后从刮擦中重新安装电报 - 更好的选择。

Shame on me, I spent a couple of days to get the answer - 20x is pre-release version only! To find clear explanation, you have to read WiKi and not even on the first page - https://github.com/python-telegram-bot/python-telegram-bot/wiki/introduction-to-the-API
That was the only source of info with clear answer with 20x status and right installation procedure.
So, here is the procedure - pip install python-telegram-bot -U --pre
btw, you have to check if "telegram" package installed also. Uninstall it first and then reinstall telegram-bot from the scratch (better with force option).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文