Library error in python?

This error appears and I cannot run its script. I tried several ways and failed until I gave up, and I am just a step away from deleting the entire project. Are there anyone who can help me?

—————————————————————

Traceback (most recent call last):
File “main. py”, line 3, in
from telegram import InlineKeyboardButto
n, InlineKeyboardMarkup, Update
ImportError: cannot import name
InlineKeybo
ardButton’ from ‘telegram’ (/home/runner/bot
-tele-mane/venv/lib/python3.10/site-package
s/telegram/init.py)

Hey, @xIArTo welcome to the forums!

Can you please provide a link to the repl? This way it is easier for staff and members of the community to help you!

Also see this guide on how to share your code:

https://replit.com/@xIArTo/bot-tele-m3ane#main.py

Looking at the error, it would appear that InlineKeyboardButton doesn’t exist the the telegram module, are you sure you’re importing it correctly?

yes , because i created this script by open ai

ChatGPT right? Do not trust GPT’s code. It has no clue what module actually do most of the time, and will make stuff up. I recommend looking at official documentation on how to do this, as the InlineKeybaordButton thing doesn’t exist.

1 Like

ChatGPT have outdated data, he can ask for you to install a previous version of the module. Be sure to use this when installing the package, so you can have the last version:

$ pip install python-telegram-bot --upgrade

In their documentation they said:

  1. “You must use exactly one of the optional fields.” - This means that each InlineKeyboardButton you create should use exactly one of the optional parameters (text, url, callback_data, switch_inline_query, etc.). If you use more than one, it might not work as expected.
1 Like

Quick note, use Perplexity because it actually looks at websites instead of what it was trained on and therefore it provides newer results.