Skip to content

[问题/Issue] 章节10.3.3:ModuleNotFoundError: No module named 'flask' #255

@tiansiyuan

Description

@tiansiyuan

1. 遇到问题的章节 / Affected Chapter

Chapter 10.3.3

2. 问题类型 / Issue Type

依赖问题 / Dependency Issue

3. 具体问题描述 / Problem Description

python 09_A2A_Server.py 
✅ 研究员Agent服务已启动在 http://localhost:5000
Exception in thread Thread-1 (start_server):
Traceback (most recent call last):
  File "/Users/tiansiyuan/Downloads/projects/hello-agent/.venv/lib/python3.12/site-packages/hello_agents/protocols/a2a/implementation.py", line 62, in run
    from flask import Flask, request, jsonify
ModuleNotFoundError: No module named 'flask'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tiansiyuan/.local/share/uv/python/cpython-3.12.10-macos-aarch64-none/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "/Users/tiansiyuan/.local/share/uv/python/cpython-3.12.10-macos-aarch64-none/lib/python3.12/threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/tiansiyuan/Downloads/projects/hello-agent/09_A2A_Server.py", line 35, in start_server
    researcher.run(host="localhost", port=5000)
  File "/Users/tiansiyuan/Downloads/projects/hello-agent/.venv/lib/python3.12/site-packages/hello_agents/protocols/a2a/implementation.py", line 64, in run
    raise ImportError(
ImportError: A2A server requires Flask. Install it with: pip install flask

安装 hello-agents 所需版本时遇到下面的警告:

uv pip install "hello-agents[protocol]==0.2.2"
Using Python 3.12.10 environment at: /Users/tiansiyuan/Downloads/projects/hello-agent/.venv
Resolved 69 packages in 2.95s
Prepared 2 packages in 3.75s
Uninstalled 2 packages in 131ms
Installed 2 packages in 8ms
 - hello-agents==0.2.8
 + hello-agents==0.2.2
 - numpy==2.3.5
 + numpy==1.26.4
warning: The package `hello-agents==0.2.2` does not have an extra named `protocol`

4. 问题重现材料 / Reproduction Materials

python 09_A2A_Server.py 

错误信息:

✅ 研究员Agent服务已启动在 http://localhost:5000
Exception in thread Thread-1 (start_server):
Traceback (most recent call last):
  File "/Users/tiansiyuan/Downloads/projects/hello-agent/.venv/lib/python3.12/site-packages/hello_agents/protocols/a2a/implementation.py", line 62, in run
    from flask import Flask, request, jsonify
ModuleNotFoundError: No module named 'flask'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tiansiyuan/.local/share/uv/python/cpython-3.12.10-macos-aarch64-none/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "/Users/tiansiyuan/.local/share/uv/python/cpython-3.12.10-macos-aarch64-none/lib/python3.12/threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/tiansiyuan/Downloads/projects/hello-agent/09_A2A_Server.py", line 35, in start_server
    researcher.run(host="localhost", port=5000)
  File "/Users/tiansiyuan/Downloads/projects/hello-agent/.venv/lib/python3.12/site-packages/hello_agents/protocols/a2a/implementation.py", line 64, in run
    raise ImportError(
ImportError: A2A server requires Flask. Install it with: pip install flask

5. 补充信息 / Additional Information

No response

确认事项 / Verification

  • 我已阅读过相关章节的文档 / I have read the relevant chapter documentation
  • 我已搜索过现有的Issues,确认此问题未被报告 / I have searched existing Issues and confirmed this hasn't been reported
  • 我已尝试过基本的故障排除(如重启、重新安装依赖等) / I have tried basic troubleshooting (restart, reinstall dependencies, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions