DEV Community

Cover image for How to Set Up CrewAI on macOS: A Step-by-Step Guide
Kven Ho
Kven Ho

Posted on • Edited on

How to Set Up CrewAI on macOS: A Step-by-Step Guide

Setting up CrewAI on macOS requires careful configuration of Python, as the tool depends on specific versions. This guide will walk you through the process using pyenv, a powerful tool that allows you to manage multiple versions of Python on your system. Let’s dive in.

1. Install and Configure pyenv

To begin, you’ll need to install pyenv, which simplifies managing different Python versions. However, it’s crucial to use a specific command to avoid missing modules later on:

env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.12.7
Enter fullscreen mode Exit fullscreen mode

This command ensures that the necessary framework support is built into Python, which is essential when running Python-based applications like CrewAI on macOS. CrewAI requires Python versions between 3.10 and 3.13 (during my writing time), so Python 3.12.7 is a safe choice.

For detailed steps on how to install Python with framework support on macOS, you can refer to the pyenv wiki.

2. Set up pyenv for Your Shell

Once you’ve installed the correct version of Python, you need to initialize pyenv so that your shell can use it. Run the following command to get the initialization script:

pyenv init
Enter fullscreen mode Exit fullscreen mode

Next, copy the output and paste it into your .zprofile or .zshrc file, depending on which shell you’re using. This ensures that pyenv is automatically loaded every time you start a new terminal session. After editing the file, restart your terminal to apply the changes.

3. Set Python Version for the Shell

Now that pyenv is set up, you need to specify which Python version to use for your current shell session. To set Python 3.12.7, use the following command:

pyenv shell 3.12.7
Enter fullscreen mode Exit fullscreen mode

Then, restart your terminal once more to ensure the change takes effect.

4. Install CrewAI and Necessary Tools

With the correct version of Python active, you can now install CrewAI and its required tools using pip. To do this, run:

pip install 'crewai[tools]'
Enter fullscreen mode Exit fullscreen mode

Once the installation is complete, restart the terminal again to ensure everything is correctly set up.

5. Create Your First CrewAI Project

You’re now ready to create your first CrewAI project. Use the following command to initialize a new project:

crewai create crew <project_name>
Enter fullscreen mode Exit fullscreen mode

This will set up a new AI-powered project that you can start building on. By following these steps, you’ll have CrewAI running smoothly on your macOS environment, ready to assist with AI-driven workflows and applications.

Conclusion

Setting up CrewAI on macOS requires a few specific steps, particularly in configuring the right Python environment. By using pyenv, you can easily manage Python versions and ensure compatibility with CrewAI. Remember to follow each step carefully, especially regarding terminal restarts, to avoid any issues along the way. With the right setup, CrewAI will be a powerful addition to your development toolkit!

Top comments (0)