-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Description
Issue I am facing
Receiving this error
ImportError: cannot import name 'AsymmetricPadding' from partially initialized module 'cryptography.hazmat.primitives.asymmetric.padding' (most likely due to a circular import) (/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py)
in this official example script.
python-telegram-bot 13.2
Python v3.9.1
pip v20.2.3
MacOS v11.1 (20C69)
Traceback to the issue
Traceback (most recent call last):
File "/Users/kirill/devbox/media_capture_bot/main.py", line 3, in <module>
from telegram import Update
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/telegram/__init__.py", line 51, in <module>
from .files.file import File
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/telegram/files/file.py", line 28, in <module>
from telegram.passport.credentials import decrypt
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/telegram/passport/credentials.py", line 29, in <module>
from cryptography.hazmat.primitives.asymmetric.padding import MGF1, OAEP
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py", line 10, in <module>
from cryptography.hazmat.primitives.asymmetric import rsa
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 20, in <module>
from cryptography.hazmat.primitives.asymmetric.padding import AsymmetricPadding
ImportError: cannot import name 'AsymmetricPadding' from partially initialized module 'cryptography.hazmat.primitives.asymmetric.padding' (most likely due to a circular import) (/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py)
Related part of your code
import logging
from telegram import Update
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
)
logger = logging.getLogger(__name__)
# Define a few command handlers. These usually take the two arguments update and
# context. Error handlers also receive the raised TelegramError object in error.
def start(update: Update, context: CallbackContext) -> None:
"""Send a message when the command /start is issued."""
update.message.reply_text('Hi!')
def help_command(update: Update, context: CallbackContext) -> None:
"""Send a message when the command /help is issued."""
update.message.reply_text('Help!')
def echo(update: Update, context: CallbackContext) -> None:
"""Echo the user message."""
update.message.reply_text(update.message.text)
def main():
"""Start the bot."""
# Create the Updater and pass it your bot's token.
updater = Updater("<my Telegram bot token here>")
# Get the dispatcher to register handlers
dispatcher = updater.dispatcher
# on different commands - answer in Telegram
dispatcher.add_handler(CommandHandler("start", start))
dispatcher.add_handler(CommandHandler("help", help_command))
# on noncommand i.e message - echo the message on Telegram
dispatcher.add_handler(MessageHandler(Filters.text & ~Filters.command, echo))
# Start the Bot
updater.start_polling()
# Run the bot until you press Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT. This should be used most of the time, since
# start_polling() is non-blocking and will stop the bot gracefully.
updater.idle()
if __name__ == '__main__':
main()Thanks in advance!
Metadata
Metadata
Assignees
Labels
No labels