[英]ImportError on Windows
我試圖在 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 上正常工作
從電報.ext 導入更新程序
添加.ext
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.