I keep running into this ModuleNotFoundError when running crewai run
presumably from the .venv it auto creates.
File “/path/to/my/project/stock_analyst/.venv/bin/run_crew”, line 5, in
from stock_analyst.main import run
ModuleNotFoundError: No module named ‘stock_analyst’
An error occurred while running the crew: Command ‘[‘uv’, ‘run’, ‘run_crew’]’ returned non-zero exit status 1.
“stock_analyst” is my project root folder’s name.
My main.py file
#!/usr/bin/env python
import sys
import warnings
from stock_analyst.crew import StockAnalyst
warnings.filterwarnings("ignore", category=SyntaxWarning, module="pysbd")
# This main file is intended to be a way for you to run your
# crew locally, so refrain from adding unnecessary logic into this file.
# Replace with inputs you want to test with, it will automatically
# interpolate any tasks and agents information
def run():
"""
Run the crew.
"""
inputs = {
"stock": 'Tesla'
}
StockAnalyst().crew().kickoff(inputs=inputs)
I didn’t change the remaining code.
crew.py header
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
# Uncomment the following line to use an example of a custom tool
# from stock_analyst.tools.custom_tool import MyCustomTool
# Check our tools documentations for more information on how to use them
# from crewai_tools import SerperDevTool
@CrewBase
class StockAnalyst():
"""StockAnalyst crew"""
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
in agents.yaml and tasks.yaml, I just modified them. One of my agents are
data_retriever:
role: >
{stock} Stock Data Retriever
goal: >
Fetch historical {stock} stock data from financial APIs.
backstory: >
You're an expert in financial data retrieval. Your skills in accessing
and processing stock market data help traders make informed decisions.
Screenshot of project structure:
Please let me know if you need more information.
Does anyone know what this problem is? Please advise, thanks