From 92d420dcc494ff30b8b335b4cb1c83571253d60d Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:31:45 +0000 Subject: [PATCH] Fix #2348: Add src directory to sys.path in run_crew.py to resolve ModuleNotFoundError Co-Authored-By: Joe Moura --- src/crewai/cli/run_crew.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/crewai/cli/run_crew.py b/src/crewai/cli/run_crew.py index 62241a4b5..48216ab75 100644 --- a/src/crewai/cli/run_crew.py +++ b/src/crewai/cli/run_crew.py @@ -1,5 +1,7 @@ import subprocess +import sys from enum import Enum +from pathlib import Path from typing import List, Optional import click @@ -54,6 +56,12 @@ def execute_command(crew_type: CrewType) -> None: Args: crew_type: The type of crew to run """ + # Add the 'src' directory to sys.path to ensure module imports work correctly + cwd = Path.cwd() + src_path = cwd / "src" + if src_path.exists() and str(src_path) not in sys.path: + sys.path.insert(0, str(src_path)) + command = ["uv", "run", "kickoff" if crew_type == CrewType.FLOW else "run_crew"] try: