首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows环境下的ImportError

Windows环境下的ImportError
EN

Stack Overflow用户
提问于 2021-03-19 21:32:50
回答 1查看 73关注 0票数 0

我试图在Windows机器上运行Python脚本,但我得到了以下错误:

代码语言:javascript
复制
"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'"

我的守则:

代码语言:javascript
复制
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上正常工作。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-19 21:40:30

从telegram.ext导入更新程序

添加.ext

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66715850

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档