Python is a programming language, and like any software, it gets updated with new features, bug fixes, and security improvements. Different projects might need different Python versions, so we often have multiple versions installed.
Think of it like having different versions of an app on your phone - sometimes you need the latest features, sometimes you need stability.
After our cleanup, here's what we have:
# Your project's virtual environment (BEST CHOICE)
Python 3.12.11 ('.venv': Poetry) - Use this for agent-catalog project| Version | Location | Purpose | When to Use |
|---|---|---|---|
| Python 3.12.11 | /opt/homebrew/bin/python3.12 |
Main development | New projects, daily coding |
| Python 3.13.5 | /opt/homebrew/bin/python3.13 |
Latest features | Testing newest Python features |
| Python 3.9.6 | /usr/bin/python3 |
System Python | Leave alone (macOS needs this) |
Short Answer: macOS (your operating system) uses it internally.
Longer Explanation:
- Apple includes Python 3.9.6 as part of macOS
- Some macOS tools and scripts expect to find Python at
/usr/bin/python3 - If we remove or change it, we might break macOS functionality
- It's like the "factory installed" software - safer to leave it alone
Yes, we can and should! Here's how:
python3 --version # Shows Python 3.9.6 (old!)python3 --version # Would show Python 3.13.5 (modern!)- System Python stays safe at
/usr/bin/python3(macOS happy) - Your terminal uses modern Python when you type
python3(You happy) - Best of both worlds!
Think of virtual environments like separate apartments:
- Each project gets its own "apartment" (environment)
- Each apartment has its own Python version and packages
- Changes in one apartment don't affect others
- No conflicts between different projects
# Location: /Users/kaustavghosh/Desktop/agent-catalog-quickstart/.venv
# Python Version: 3.12.11
# Managed by: Poetry
# Status: ✅ Ready to use# Activate the project environment
poetry shell
# Or run commands directly
poetry run python your_script.py# Create a new project with specific Python version
/opt/homebrew/bin/python3.12 -m venv my_new_project
cd my_new_project
source bin/activate# Use Python 3.13
/opt/homebrew/bin/python3.13 -m venv test_env
cd test_env
source bin/activate# Check what 'python3' points to
python3 --version
# Check specific versions
/opt/homebrew/bin/python3.12 --version
/opt/homebrew/bin/python3.13 --version
/usr/bin/python3 --version
# See all Python installations
ls -la /opt/homebrew/bin/python*# Check current project's environment
poetry env info
# Activate project environment
poetry shell
# Install packages in project
poetry add package_name
# Run scripts in project environment
poetry run python script.py| What | Why Removed |
|---|---|
| Python 3.11.x | Outdated, not needed for current project |
| Python 3.12.8 | Older patch version (3.12.11 is newer) |
| Broken symlinks | Pointing to deleted Python installations |
| Old .python-version | Referencing removed Python version |
| What | Why Kept |
|---|---|
| Python 3.9.6 (system) | Required by macOS |
| Python 3.12.11 | Project requirement, stable |
| Python 3.13.5 | Latest features, future-proofing |
| Poetry virtual env | Project dependencies |
Here's the detailed step-by-step process we used to clean up your Python installation. Don't run these commands again - this is just for educational purposes!
First, we examined what Python versions were installed:
# Check Homebrew Python installations
brew list | grep python
# Result: python@3.12, python@3.13 (good to keep)
# Check pyenv-managed versions
pyenv versions
# Result: Found Python 3.12.8 (older patch version)
# Check system Python locations
ls -la /usr/local/bin/python* /opt/homebrew/bin/python* /usr/bin/python*
# Result: Found old symlinks and framework installations# Remove the older Python 3.12.8 from pyenv
pyenv uninstall -f 3.12.8
# ✅ Result: Removed older patch version
# Reset pyenv to use system Python
pyenv global system
# ✅ Result: No longer forcing old Python versionWhy this step?
- Python 3.12.8 was an older patch version
- Python 3.12.11 (Homebrew) is newer and better maintained
- Prevents version conflicts
# Remove old Python 3.11 symlinks in /usr/local/bin
sudo rm -f /usr/local/bin/python /usr/local/bin/python3
# ✅ Result: Removed broken links pointing to deleted Python 3.11Why this step?
- These symlinks pointed to Python 3.11 framework we were going to remove
- Broken symlinks cause confusion and errors
- Better to have no link than a broken link
# Remove the entire Python 3.11 framework
sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.11
# ✅ Result: Freed up disk space, removed outdated PythonWhy this step?
- Python 3.11 was outdated (your project needs 3.12+)
- Framework installations can conflict with Homebrew versions
- This was taking up unnecessary disk space
# Remove .python-version file pointing to deleted version
rm .python-version
# ✅ Result: Removed reference to deleted Python 3.12.8Why this step?
- The file was telling pyenv to use Python 3.12.8 (which we removed)
- This was causing "version not installed" errors
- Better to use default system behavior
# Clean up Homebrew caches and orphaned files
brew cleanup
# ✅ Result: Freed up additional disk spaceWhy this step?
- Removes cached files from deleted installations
- Frees up disk space
- Keeps Homebrew installation clean
# Install Poetry using the clean Python 3.12 installation
curl -sSL https://install.python-poetry.org | /opt/homebrew/bin/python3.12 -
# ✅ Result: Poetry installed and working with correct Python versionWhy this step?
- Poetry wasn't found in PATH after cleanup
- Installing with Python 3.12 ensures compatibility
- Poetry is essential for this project's dependency management
# Add Homebrew Python to PATH priority
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
# ✅ Result: Homebrew bin directory added to front of PATH
# Apply the changes
source ~/.zshrc
# ✅ Result: Modern Python now default while system stays safeWhy this step?
- Makes Python 3.13.5 your daily default instead of 3.9.6
- Keeps system Python completely safe and untouched
- Provides modern Python features for development
- Still allows specific version access when needed
# Verify the complete setup
python3 --version # ✅ Python 3.13.5 (new default!)
which python3 # ✅ /opt/homebrew/bin/python3
/usr/bin/python3 --version # ✅ Python 3.9.6 (system safe)
poetry --version # ✅ Poetry (version 2.1.3)
poetry run python --version # ✅ Python 3.12.11 (project env)
poetry env info # ✅ Project env using Python 3.12.11❌ Python 3.9.6 (system) - outdated default
❌ Python 3.11.x (framework) - outdated, conflicting
❌ Python 3.12.8 (pyenv) - old patch version
❌ Python 3.12.11 (homebrew) - good but not prioritized
❌ Python 3.13.5 (homebrew) - good but unused
❌ Broken symlinks and configs
❌ Poetry not working
✅ Python 3.13.5 (homebrew) - NEW DEFAULT for daily use
✅ Python 3.12.11 (homebrew) - project standard
✅ Python 3.9.6 (system) - safe, untouched (macOS protected)
✅ Clean configurations
✅ Working Poetry installation
✅ Proper virtual environment
✅ Modern Python as default while keeping system safe
- Safety First: Never touched system Python (
/usr/bin/python3) - Keep Modern Versions: Preserved Python 3.12+ installations
- Remove Conflicts: Eliminated competing installations
- Clean Configs: Removed stale configuration files
- Verify Everything: Tested each component after cleanup
- System Python 3.9.6: macOS needs this
- Homebrew Python 3.12: Required for project
- Homebrew Python 3.13: Latest stable version
- Project .venv folder: Contains all project dependencies
- Always investigate first - understand what you have before removing
- Start with least risky changes - remove pyenv versions before system files
- Keep backups - especially of working virtual environments
- Verify at each step - make sure each removal doesn't break anything
- Document everything - know what you removed and why
This cleanup process transformed a messy Python installation into a clean, professional development environment! 🚀
We've successfully implemented Python 3.13 as your default Python while keeping the system safe!
# Your new default (modern Python)
python3 --version # ✅ Python 3.13.5
which python3 # ✅ /opt/homebrew/bin/python3
# System Python (safe & untouched)
/usr/bin/python3 --version # ✅ Python 3.9.6 (macOS protected)
# Project environment (perfect)
poetry run python --version # ✅ Python 3.12.11 (in virtual env)We added Homebrew's bin directory to the front of your PATH in ~/.zshrc:
# This line was added to ~/.zshrc
export PATH="/opt/homebrew/bin:$PATH"- ✅ System Python untouched - macOS functionality preserved
- ✅ Modern Python as default - better development experience
- ✅ Project environment intact - agent-catalog works perfectly
- ✅ Reversible change - can be undone if needed
| When You Type | You Get | Purpose |
|---|---|---|
python3 |
Python 3.13.5 | Daily development work |
python3.12 |
Python 3.12.11 | Specific version if needed |
/usr/bin/python3 |
Python 3.9.6 | System Python (unchanged) |
poetry run python |
Python 3.12.11 | Your project's requirements |
- Always use virtual environments for projects
- Use Poetry for this agent-catalog project
- Keep system Python untouched
- Specify Python version when creating new projects
- Update packages regularly in virtual environments
- Don't modify
/usr/bin/python3(system Python) - Don't install packages globally with pip
- Don't delete system Python
- Don't mix packages between different projects
-
"Command not found: poetry"
# Poetry is in ~/.local/bin, add to PATH: export PATH="$HOME/.local/bin:$PATH"
-
"Wrong Python version in project"
poetry env use /opt/homebrew/bin/python3.12
-
"Package conflicts"
# Use virtual environments! poetry shell # for this project
# Test your setup right now:
python3 --version # Should show: Python 3.13.5
which python3 # Should show: /opt/homebrew/bin/python3
/usr/bin/python3 --version # Should show: Python 3.9.6 (system safe)
poetry run python --version # Should show: Python 3.12.11 (project)| ✅ What You Have | 📝 Description |
|---|---|
| Modern Default | Python 3.13.5 when you type python3 |
| Project Environment | Python 3.12.11 in your agent-catalog virtual env |
| System Safety | Python 3.9.6 preserved for macOS |
| Clean Setup | No conflicting installations |
| Professional Tools | Poetry working perfectly |
| Best Practices | Virtual environments for isolation |
You now have the IDEAL Python development setup:
- ✅ Modern Python 3.13.5 as your daily default
- ✅ Project-specific Python 3.12.11 for agent-catalog
- ✅ System Python 3.9.6 safely preserved for macOS
- ✅ Clean virtual environment with all dependencies
- ✅ Poetry for professional dependency management
- ✅ Zero conflicts between different Python versions
- Daily coding: Just type
python3(gets 3.13.5) - Agent-catalog project: Use
poetry shellorpoetry run - New projects: Create with
/opt/homebrew/bin/python3.12 -m venv - System tools: macOS continues working normally
Your setup now follows industry best practices and gives you the best development experience possible! 🎉
If you also work on Linux systems, be aware of platform differences:
Linux-Specific Issues:
- EXTERNALLY-MANAGED error: Ubuntu/Debian systems block
pipby default - Solution documented: See
PYTHON_LINUX.mdfor the complete fix - Different approach needed: Linux requires removing restriction file
macOS vs Linux Python Management:
| Aspect | macOS (This Guide) | Linux (Ubuntu/Debian) |
|---|---|---|
| System Python | /usr/bin/python3 (3.9.6) |
/usr/bin/python3 (varies) |
| Package Manager | Homebrew + pip work together | apt conflicts with pip |
| Default pip | Works normally | Blocked by EXTERNALLY-MANAGED |
| Best Practice | Use Homebrew versions | Remove restriction file |
| Virtual Environments | Optional, Poetry recommended | Optional after fix |
Cross-Platform Project Setup:
# Works on both macOS and Linux (after our fixes)
pip install package-name # Standard approach
poetry install # For this agent-catalog project
python3 -m venv env # Virtual env if neededYour agent-catalog project works identically on both platforms:
# Same commands work everywhere
poetry shell
poetry run python script.py
poetry add new-package- ✅ macOS: Modern Python as default (this guide)
- ✅ Linux: EXTERNALLY-MANAGED restriction removed (see PYTHON_LINUX.md)
- ✅ Both: Poetry working for agent-catalog project
- ✅ Both: Standard pip workflow restored
- ✅ Both: Professional development environment
python3 --version # Python 3.13.5 (Homebrew default)
which python3 # /opt/homebrew/bin/python3
brew install python@3.12 # Install specific version
poetry shell # Project environmentpython3 --version # System Python (varies by distro)
which python3 # /usr/bin/python3
sudo apt install python3-pip # Install pip if missing
poetry shell # Project environmentThese guides provide professional-grade Python environments for both macOS and Linux that many senior developers would be proud to have.