DS DevShelfHub Projects · AI tools
Tutorials / AI Agents / Installation & Setup
Build with CrewAI Beginner · 8 min read Page 3 of 29

How to Install CrewAI and Configure Python Environments

By DevShelfHub

Get CrewAI running locally in 5 minutes: virtualenv, dependencies, API keys, and your first verification run.

Series progress3 / 29
CrewAI installation setup tutorial — How to Install CrewAI and Configure Python Environments

Install CrewAI

CrewAI requires Python 3.10+. Use a virtual environment — agents pull in many dependencies.

Create a virtualenv and install

BASH
python3 -m venv .venv
source .venv/bin/activate    # Windows: .venv\Scripts\activate

pip3 install --upgrade pip
pip3 install crewai crewai-tools

💡 Tip: crewai-tools is the optional toolbelt (search, scraping, file I/O). Install it now — you'll need it by Page 7.

Configure API Keys

CrewAI uses an LLM provider under the hood — OpenAI by default. Put keys in a .env file at your project root:

.env

BASH
# Required for default OpenAI usage
OPENAI_API_KEY=sk-...

# Optional: Serper for web search tool
SERPER_API_KEY=...

# Optional: Anthropic, Groq, etc.
ANTHROPIC_API_KEY=sk-ant-...

Load it from Python

PYTHON
from dotenv import load_dotenv
load_dotenv()  # picks up .env in current directory

Verify Your Install

Save this as hello_crew.py and run it. If you see an answer, you're good to go.

hello_crew.py

PYTHON
from dotenv import load_dotenv
from crewai import Agent, Task, Crew

load_dotenv()

assistant = Agent(
    role="Friendly Assistant",
    goal="Answer questions clearly in one sentence",
    backstory="You are concise and warm.",
    verbose=True,
)

greet = Task(
    description="Say hello and confirm you are working.",
    expected_output="A one-sentence greeting.",
    agent=assistant,
)

crew = Crew(agents=[assistant], tasks=[greet])
print(crew.kickoff())

Run it

BASH
python3 hello_crew.py

Common Setup Issues

AuthenticationError: 401

Your OPENAI_API_KEY is missing or wrong. Double-check the .env and that load_dotenv() ran.

ModuleNotFoundError: No module named 'crewai'

Wrong virtualenv active. Run which python — should point inside .venv.

❌ Hangs forever / costs spiking

Set max_iter=5 on each agent during dev. Default is 25 — easy to burn tokens.

Notes

Pin both CrewAI and provider clients

Upstream SDK changes can alter retries, timeouts, and token accounting. Lock transitive dependencies in CI images, not only top-level pins.

Smoke test with the smallest real key

A hello-world kickoff validates networking, DNS, and key scopes faster than debugging inside a large crew. Automate that smoke test in staging deploys.

Windows paths and SSL stores differ

Corporate proxies and custom CA bundles break TLS in subtle ways. Document any extra cert env vars your team needs beyond macOS defaults.

Virtualenvs per service prevent dependency soup

Mixing agent frameworks in one environment invites version conflicts. Keep CrewAI services isolated even during local experimentation.

CrewAI installation FAQ

How do I install CrewAI with pip?

Create a virtual environment, upgrade pip, then install the crewai package pin compatible versions for your provider clients. Re-run a smoke kickoff after upgrades.

Where should CrewAI API keys live?

Store keys in environment variables or a local dotenv file that never ships to git. Inject them at runtime through your process manager in production.

Does CrewAI require a GPU?

No. CrewAI orchestrates LLM calls remotely for most setups. GPUs matter only if you self-host models locally with compatible backends.

How do I verify a CrewAI install?

Run a minimal crew with verbose logging and a cheap model to confirm imports, credentials, and provider connectivity before layering tools or memory.

What Python version should I use with CrewAI?

Use a supported modern Python release per CrewAI's documentation, and match it in CI so local and deployed environments stay aligned.

See also: DevShelfHub's CrewAI tool review for a product-level comparison, pricing notes, and links back into this tutorial series.

Quick jump: API Reference