Last modified: Jun 06, 2026

Install CrewAI in Python

CrewAI is a powerful framework for building multi-agent systems in Python. It helps you coordinate AI agents to work together on complex tasks.

Before you can use CrewAI, you need to install it correctly. This guide shows you how to install CrewAI on any operating system.

What is CrewAI?

CrewAI lets you create teams of AI agents. Each agent has a specific role and goal. They collaborate to solve problems, generate content, or automate workflows.

The framework is built on top of LangChain. It uses large language models like GPT-4 or Claude to power the agents.

Prerequisites

You need Python 3.10 or higher installed on your machine. Check your Python version with this command:


python --version

If you don't have Python, download it from the official Python website. Make sure to check "Add Python to PATH" during installation.

You also need pip, the Python package manager. Most Python installations include pip by default.

Step 1: Create a Virtual Environment

Always use a virtual environment. It keeps your project dependencies isolated from other projects.

Open your terminal or command prompt. Navigate to your project folder and run:


python -m venv crewai_env

This creates a folder called crewai_env with a fresh Python environment.

Activate the virtual environment:

  • Windows:crewai_env\Scripts\activate
  • macOS/Linux:source crewai_env/bin/activate

You should see (crewai_env) in your terminal prompt. This means the environment is active.

Step 2: Install CrewAI with pip

With the virtual environment active, install CrewAI using pip:


pip install crewai

This installs the core CrewAI library and all its dependencies. The installation takes about 1-2 minutes.

If you plan to use CrewAI with tools like web search or file reading, install the tools package too:


pip install 'crewai[tools]'

This extra package includes pre-built tools for common tasks. It saves you from writing everything from scratch.

Step 3: Verify the Installation

Check that CrewAI installed correctly. Run a quick Python script to import the library:


python -c "import crewai; print(crewai.__version__)"

You should see a version number like 0.28.0. If you get an error, check your virtual environment is active and pip installation succeeded.

Step 4: Set Up Your API Key

CrewAI needs an API key to access a language model. The most common choice is OpenAI's GPT models.

Get your API key from the OpenAI dashboard. Then set it as an environment variable:


export OPENAI_API_KEY="your-api-key-here"

On Windows Command Prompt, use set OPENAI_API_KEY=your-api-key-here. On PowerShell, use $env:OPENAI_API_KEY="your-api-key-here".

You can also create a .env file in your project folder. Install python-dotenv and load the key automatically.

Step 5: Run Your First CrewAI Project

Create a new Python file called test_crew.py. Add this simple example:


from crewai import Agent, Task, Crew, Process

# Define a simple agent
researcher = Agent(
    role="Researcher",
    goal="Find interesting facts about space",
    backstory="You are a curious space enthusiast",
    verbose=True
)

# Define a task
research_task = Task(
    description="Tell me one fact about the moon",
    expected_output="A short fact about the moon",
    agent=researcher
)

# Create the crew
crew = Crew(
    agents=[researcher],
    tasks=[research_task],
    process=Process.sequential
)

# Run the crew
result = crew.kickoff()
print(result)

Run the script:


python test_crew.py

You should see output like:


The moon is about 4.5 billion years old, formed shortly after the Earth.

This confirms CrewAI is working. The agent completed its task and returned a fact.

Troubleshooting Common Issues

Error: "No module named crewai" – Your virtual environment may not be active. Activate it and try again.

Error: "OpenAI API key not found" – Set the OPENAI_API_KEY environment variable correctly. Double-check there are no spaces around the equals sign.

Error: "Version conflict with LangChain" – Create a fresh virtual environment. Install only CrewAI without other LangChain packages first.

If you still face issues, check the official CrewAI documentation or GitHub repository for updates.

Best Practices for CrewAI Installation

Always use a dedicated virtual environment for each CrewAI project. This prevents dependency conflicts between different projects.

Keep your CrewAI version updated. Run pip install --upgrade crewai periodically to get the latest features and bug fixes.

Store your API keys securely. Never hardcode them in your scripts. Use environment variables or a .env file that you add to .gitignore.

Conclusion

Installing CrewAI in Python is straightforward. Create a virtual environment, install with pip, set your API key, and you're ready to build multi-agent systems.

Start with simple agent teams. Experiment with different roles and tasks. As you get comfortable, explore advanced features like custom tools and conditional workflows.

CrewAI opens up powerful possibilities for automation and collaboration between AI agents. Now you have everything you need to begin your journey.