You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用BotBuilder Python库遇ModuleNotFoundError问题求助

解决botbuilder.dialogs模块找不到的问题

问题描述

此前运行正常的开源bot-builder library及multi-turn-prompt示例代码,3天前突然无法运行。在VS Code中执行代码时抛出错误:

ModuleNotFoundError: No module named 'botbuilder.dialogs'.

执行pip install -r requirements.txt安装依赖时,系统显示依赖已存在:

Requirement already satisfied: botbuilder.dialogs>=4.8.0 in
c:\users---\botbuilder-samples\samples\python\05.multi-turn-prompt\botbuilder-python\libraries\botbuilder-dialogs
(from -r requirements.txt (line 2)) (4.15.0)

环境信息:Windows 11 Enterprise,Python 3.11.3


解决步骤

  • 核对VS Code的Python解释器路径
    点击VS Code左下角的Python版本选择器,确认当前选中的解释器路径,和安装botbuilder.dialogs的路径完全一致。多个Python环境(系统环境、虚拟环境)共存时,VS Code可能默认使用了未安装对应依赖的环境。

  • 重新安装依赖到当前环境
    若确认解释器路径正确,先卸载现有包再重新安装:

    pip uninstall botbuilder.dialogs -y
    pip install -r requirements.txt
    
  • 检查本地库路径是否被Python识别
    从提示看,包安装在了项目内的botbuilder-python\libraries\botbuilder-dialogs目录,可能该路径未被Python的搜索路径包含。可在代码开头添加以下代码验证:

    import sys
    print(sys.path)
    

    如果输出中没有该目录路径,手动添加:

    import sys
    import os
    sys.path.append(os.path.abspath("./botbuilder-python/libraries"))
    
  • 使用虚拟环境隔离依赖
    为避免环境冲突,在项目目录下创建并使用虚拟环境:

    # 创建虚拟环境
    python -m venv .venv
    # Windows PowerShell激活虚拟环境
    .\.venv\Scripts\Activate.ps1
    # 激活后安装依赖
    pip install -r requirements.txt
    

    激活完成后,在VS Code中选择该虚拟环境的解释器即可。

内容的提问来源于stack exchange,提问作者epeka

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 05:12:05