Install Python

macOS now comes with python, but we are best served by having more control over which version of python we use. One method is to use brew install python.

However we wish to use pyenv and pyenv-virtualenv for isolated AI agent tooling. This tutorial is what I largely used for my setup - medium

brew install pyenv pyenv-virtualenv

Now we need to fix our setup on macOS - in my case for using zsh. I adapted the suggestion in th tutorial to use:

eval "$(pyenv init -)" if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi

Without it we get an error:

Installed Python-3.12.3 to /Users/david/.pyenv/versions/3.12.3 zsh: command not found: # Failed to activate virtualenv. Perhaps pyenv-virtualenv has not been loaded into your shell properly. Please restart current shell and try again. zsh: command not found: pip

In the end i used the following up with the following `~/.zshrc` file (use `nano -w ~/.zshrc`):

# --- Node Version Manager (NVM) --- export NVM_DIR="$HOME/.nvm" [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" [ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # --- Pyenv + pyenv-virtualenv --- eval "$(pyenv init -)" # Initializes pyenv for version switching if command -v pyenv-virtualenv-init >/dev/null; then eval "$(pyenv virtualenv-init -)" # Enables virtualenv auto-activation fi

Now that we have pyenv working we can go ahead with:

# Install your preferred Python version — e.g., 3.12.3 pyenv install 3.12.3 pyenv virtualenv 3.12.3 ai-env # Activate it pyenv activate ai-env pip install open-interpreter

Which is a long detailed installation. When it is all scrolled by we can test things. You shoudl see that your virtual environment is activated:

(ai-env) david@david yam-demo %

To be sure its working in your current shell let's reload your shell:

source ~/.zshrc

You may get a notice like:

[notice] A new release of pip is available: 24.0 -> 25.1.1 [notice] To update, run: python -m pip install --upgrade pip

So upgrade as indicated:

python -m pip install --upgrade pip

# See