1.2 KiB
1.2 KiB
Installing Python 3 on macOS with Homebrew
This guide provides a concise overview of installing Python 3 on an M2 MacBook Air using Homebrew, and setting up pip and venv for a robust Python development environment.
Prerequisites
- Access to Terminal
- Connectivity to the Internet
Step 1: Install Homebrew
Open Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install Python 3
Install Python 3, which includes pip3 and venv, by running:
brew install python
Step 3: Verify Python 3 Installation
Check the Python version to verify installation:
python3 --version
Step 4: Verify pip Installation
Ensure pip3 is installed:
pip3 --version
Step 5: Setup Virtual Environments with venv
Navigate to your project directory:
cd path/to/your/project
Create a virtual environment:
python3 -m venv venv
Activate the virtual environment:
source venv/bin/activate
Step 6: Deactivate Virtual Environment
To exit the virtual environment:
deactivate
This guide ensures you have a functional Python environment on macOS, ideal for development activities.