我试图在Windows机器上运行Python脚本,但我得到了以下错误:
"Traceback (most recent call last):
File "D:\Python\telegram\main.py", line 4, in <module>
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
File "C:\Users\Balcony\AppData\Local\Programs\Python\Python39\lib\site-packages\telegram\ext\__init__.py", line 27, in <module>
from .jobqueue import JobQueue, Job
File "C:\Users\Balcony\AppData\Local\Programs\Python\Python39\lib\site-packages\telegram\ext\jobqueue.py", line 26, in <module>
import pytz
ModuleNotFoundError: No module named 'pytz'"我的守则:
import logging
import requests
import re
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from telegram.ext import KeyboardButton
# 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, context):
"""Send a message when the command /start is issued."""
update.message.reply_text('Hi!')
def help(update, context):
"""Send a message when the command /help is issued."""
update.message.reply_text(f'Help! 1234')
def echo(update, context):
"""Echo the user message."""
update.message.reply_text(f'Вы написали: {update.message.text}')
print(update.message.text)当然,我安装了所有的软件包。
并且相同的py文件在MacOS上正常工作。
发布于 2021-03-19 21:40:30
从telegram.ext导入更新程序
添加.ext
https://stackoverflow.com/questions/66715850
复制相似问题