1. Make sure Python 3.11 is installed
Check if it’s already available:
python3.11 –version
If you see something like Python 3.11.x, you’re good.
If not, install it with Homebrew (recommended):
brew install [email protected]
After installation, ensure it’s linked:
brew link [email protected]
2. Create a virtual environment
Pick a folder for your project, then run:
cd ~/myproject
python3.11 -m venv venv
This will create a virtual environment named venv inside your project.
3. Activate the virtual environment
Run:
source venv/bin/activate
You should now see (venv) in your terminal prompt.
4. Install packages inside the venv
For example:
pip install requests
All packages will now install only inside this environment.
5. Deactivate when done
Exit the venv with:
deactivate
⚡ Pro tip: If you want Python 3.11 to always be available as the default python3, you can add this to your shell config (~/.zshrc or ~/.bashrc):
alias python=python3.11
alias pip=pip3.11
Then reload:
source ~/.zshrc
