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

xlwings quickstart创建项目点击Run Main报错:ModuleNotFoundError

xlwings运行报错:ModuleNotFoundError: No module named 'hallo_welt'
  • 已完成环境配置:终端安装xlwings,添加Excel插件并在VBA工具区启用xlwings按钮
  • 执行项目创建命令:
    xlwings quickstart hallo_welt
    
  • 生成hallo_welt文件夹,内含同名Python脚本与xlsm文件,但点击「Run Main」按钮时触发报错:
    error:Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'hallo_welt'
    
  • 所用Python代码:
    import xlwings as xw
    
    def main():
        wb = xw.Book.caller()
        sheet = wb.sheets[0]
        if sheet["A1"].value == "Hello xlwings!":
            sheet["A1"].value = "Bye xlwings!"
        else:
            sheet["A1"].value = "Hello xlwings!"
    
    if __name__ == "__main__":
        xw.Book("hallo_welt.xlsm").set_mock_caller()
        main()
    
  • 预期结果:首次点击「Run Main」时,A1单元格显示「Hello xlwings!」

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.22 10:47:08