{"record":{"id":"0f74f9e4e74856b0","repo":"datawhalechina/hello-agents","slug":"notebook","errorCode":null,"errorMessage":"未找到项目目录，请从项目目录或仓库根目录启动 Notebook","messagePattern":"未找到项目目录，请从项目目录或仓库根目录启动 Notebook","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"Co-creation-projects/zenith191-RequirementClarifierAgent/main.ipynb","lineNumber":55,"sourceCode":"    \"from pathlib import Path\\n\",\n    \"\\n\",\n    \"from dotenv import load_dotenv\\n\",\n    \"from hello_agents import HelloAgentsLLM, SimpleAgent, ToolRegistry\\n\",\n    \"from hello_agents.tools import Tool, ToolParameter\\n\",\n    \"from IPython.display import Markdown, display\\n\",\n    \"\\n\",\n    \"project_name = \\\"zenith191-RequirementClarifierAgent\\\"\\n\",\n    \"candidates = [\\n\",\n    \"    Path.cwd(),\\n\",\n    \"    Path.cwd() / \\\"Co-creation-projects\\\" / project_name,\\n\",\n    \"    Path.cwd().parent / project_name,\\n\",\n    \"]\\n\",\n    \"PROJECT_ROOT = next(\\n\",\n    \"    (path.resolve() for path in candidates if (path / \\\"main.py\\\").exists()),\\n\",\n    \"    None,\\n\",\n    \")\\n\",\n    \"if PROJECT_ROOT is None:\\n\",\n    \"    raise FileNotFoundError(\\\"未找到项目目录，请从项目目录或仓库根目录启动 Notebook\\\")\\n\",\n    \"if str(PROJECT_ROOT) not in sys.path:\\n\",\n    \"    sys.path.insert(0, str(PROJECT_ROOT))\\n\",\n    \"\\n\",\n    \"load_dotenv(PROJECT_ROOT / \\\".env\\\")\\n\",\n    \"\\n\",\n    \"from src.agents import build_agent_team\\n\",\n    \"from src.config import LLMSettings\\n\",\n    \"from src.tools import create_tool_registry\\n\",\n    \"from src.workflow import RequirementClarifierWorkflow\\n\",\n    \"\\n\",\n    \"print(f\\\"✅ 环境配置完成：{PROJECT_ROOT}\\\")\"\n   ]\n  },\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## 第2部分：工具定义\\n\",","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/zenith191-RequirementClarifierAgent/main.ipynb#L37-L73","documentation":"FileNotFoundError raised by the RequirementClarifierAgent notebook's bootstrap cell when none of the three candidate directories (cwd, cwd/Co-creation-projects/<project>, cwd.parent/<project>) contains main.py. The cell uses PROJECT_ROOT discovery so imports from src.* and .env loading work regardless of where Jupyter was started; if no candidate matches, it refuses to continue rather than importing the wrong package or silently skipping dotenv.","triggerScenarios":"Starting Jupyter from any directory that is not the project directory, the repo root, or a parent of the project (e.g. ~ or /tmp); the project was cloned/renamed so the folder is not literally 'zenith191-RequirementClarifierAgent'; main.py deleted or not yet created in a work-in-progress repo; symlinked paths where Path.cwd().parent resolution differs from expectation.","commonSituations":"Running the notebook through VS Code/JupyterLab opened at a random folder; running via nbconvert/papermill from an automation cwd; nested-clone layouts (repo inside another repo) making cwd.parent/<name> miss; case-sensitivity or trailing-space differences in the cloned directory name.","solutions":["Start Jupyter from the repo root (so cwd/Co-creation-projects/zenith191-RequirementClarifierAgent resolves) or from the project directory itself, then re-run the cell.","Verify the project folder name matches 'zenith191-RequirementClarifierAgent' exactly and contains main.py; rename the folder or adjust project_name if it differs.","For headless runs (papermill/nbconvert), pass the correct working directory or add the absolute project path as an extra candidate in the list.","If main.py genuinely does not exist yet (early scaffold), create it or change the detection marker to a file that does exist (e.g. pyproject.toml)."],"exampleFix":"// before\ncandidates = [\n    Path.cwd(),\n    Path.cwd() / \"Co-creation-projects\" / project_name,\n    Path.cwd().parent / project_name,\n]\nPROJECT_ROOT = next((p.resolve() for p in candidates if (p / \"main.py\").exists()), None)\n\n// after (allow explicit override + richer marker)\ncandidates = [\n    Path(os.environ.get(\"RCA_PROJECT_ROOT\", \"\")) if os.environ.get(\"RCA_PROJECT_ROOT\") else None,\n    Path.cwd(),\n    Path.cwd() / \"Co-creation-projects\" / project_name,\n    Path.cwd().parent / project_name,\n]\nPROJECT_ROOT = next(\n    (p.resolve() for p in candidates if p and (p / \"main.py\").exists()),\n    None,\n)","handlingStrategy":"fallback","validationCode":"from pathlib import Path\nimport os\n\nPROJECT_NAME = \"zenith191-RequirementClarifierAgent\"\n\ndef find_project_root() -> Path | None:\n    override = os.environ.get(\"RCA_PROJECT_ROOT\")\n    candidates = [\n        Path(override) if override else None,\n        Path.cwd(),\n        Path.cwd() / \"Co-creation-projects\" / PROJECT_NAME,\n        Path.cwd().parent / PROJECT_NAME,\n        Path(__file__).resolve().parent if \"__file__\" in globals() else None,\n    ]\n    return next((p.resolve() for p in candidates if p and (p / \"main.py\").exists()), None)\n\nroot = find_project_root()\nif root is None:\n    raise SystemExit(f\"未找到 {PROJECT_NAME}：请从项目目录或仓库根目录启动，或设置 RCA_PROJECT_ROOT\")","typeGuard":null,"tryCatchPattern":"try:\n    PROJECT_ROOT = next((p.resolve() for p in candidates if (p / \"main.py\").exists()), None)\n    if PROJECT_ROOT is None:\n        raise FileNotFoundError(\"未找到项目目录，请从项目目录或仓库根目录启动 Notebook\")\nexcept FileNotFoundError as e:\n    print(f\"{e} — 候选路径: {[str(c) for c in candidates]}\")\n    raise","preventionTips":["Launch Jupyter from the repo root or the project directory; avoid arbitrary folders.","Support an env-var override (e.g. RCA_PROJECT_ROOT) for papermill/nbconvert automation.","Print the candidate paths in the error so users can see which locations were tried.","Detect the project by a stable marker (pyproject.toml) in addition to main.py."],"tags":["notebook","path-resolution","bootstrap","working-directory"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}