Why Python for AI?
Python is the universal language of AI and machine learning. Every major AI framework—PyTorch, TensorFlow, LangChain, Hugging Face—is built for Python. If you want to work with AI, Python is non-negotiable.
Step 1: Install Python 3.11+
You need Python 3.11 or newer for modern AI libraries. Using Homebrew (which you already installed):
brew install [email protected]
This installs Python 3.11 alongside any existing Python versions. Homebrew handles all dependencies automatically.
Alternative: Download directly from python.org if you prefer the official installer.
Step 2: Verify Installation
Check that Python is installed and accessible:
python3 --version
pip3 --version
You should see Python 3.11.x (or newer). pip3 is Python's package manager—you'll use it to install AI libraries.
Step 3: Test Python Works
Run a quick Python command to confirm everything works:
python3 -c "print('Hello, AI Developer!')"
If you see Hello, AI Developer! printed, Python is working correctly.
Step 4: Install Essential AI Packages
These are the foundational packages every AI developer needs:
pip3 install numpy pandas matplotlib scikit-learn
numpy
Numerical computing, arrays, matrices
pandas
Data manipulation and analysis
matplotlib
Data visualization and plotting
scikit-learn
Machine learning algorithms
Step 5: Set Python 3.11 as Default (Optional)
If you want python3 to always use 3.11, add an alias to your shell config:
echo 'alias python3="/opt/homebrew/bin/python3.11"' >> ~/.zshrc
echo 'alias pip3="/opt/homebrew/bin/pip3.11"' >> ~/.zshrc
source ~/.zshrc
Now python3 will always use Python 3.11.
What's Next?
Now that Python is installed, you need to learn about virtual environments—isolated spaces for each AI project so dependencies don't conflict.
→ Virtual Environments Guide