Python on an Apple

Welcome to this straightforward guide on setting up your Python programming environment on macOS. I’ll guide you through the installation process, providing concise and practical steps. Links to additional documentation and tutorials are included for each step.

Please note that not every step may be necessary for your particular needs. There are various approaches to configuring a Python environment, and this guide presents just one possibility. If you have any useful tools or steps you’ve discovered in your setup process, feel free to share them in the comments. Your contributions could be valuable to other readers.

Step 1: Install Visual Studio Code

Visual Studio Code is a lightweight and powerful code editor that is perfect for data science projects. You can download it from the official website here.

  1. Download VS Code: Visit the Visual Studio Code download page and click on the macOS download button.
  2. Install: Open the downloaded .zip file and drag the Visual Studio Code.app to your Applications folder.
  3. Launch VS Code: Open Visual Studio Code from the Applications folder or via Spotlight Search.

Step 2: Install Homebrew

Homebrew is a package manager for macOS that simplifies the installation of software. Visit the official website for more information and installation instructions. Open a terminal and type brew --version to verify your installation.

Step 3: Ensure Zsh is Installed and Set as Default Shell

Starting from macOS Catalina (10.15), Zsh is the default shell. You can check your current shell by running:

echo $SHELL

If the output is /bin/zsh, you're already using Zsh. If not, you can change the default shell to Zsh:

chsh -s /bin/zsh
  1. Install Zsh (Only if necessary!): If you’re on an older macOS version and Zsh isn’t installed, you can install it using Homebrew:
brew install zsh

Step 4: Install Oh My Zsh

Oh My Zsh is a community-driven framework for managing your Zsh configuration. Please follow the installation instructions available here.

Step 5: Install Zsh Plugins

Enhance your command-line experience with these Zsh plugins.

  1. Autosuggestions Plugin: Provides suggestions based on your command history.
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

2. Syntax Highlighting Plugin: Highlights syntax in your terminal.

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

3. Fast Syntax Highlighting Plugin: Offers faster syntax highlighting.

git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting

4. Autocomplete Plugin: Provides advanced autocomplete functionality.

git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autocomplete

Step 6: Configure Zsh

Enable the installed plugins by editing your Zsh configuration.

  1. Open .zshrc:
vim ~/.zshrc

2. Modify Plugins Line:

3. Find the line :

plugins=(git)

4. Replace it with:

plugins=(git zsh-autosuggestions zsh-syntax-highlighting fast-syntax-highlighting zsh-autocomplete)

5. Save and Exit: Press Esc, type :wq, and press Enter.

6. Reload Zsh Configuration:

source ~/.zshrc

Step 7: Install uv and Python

uv is a fast, all-in-one Python package and project manager from Astral. It replaces the need for separate tools like pip, pyenv, virtualenv, and conda.

1. Install uv via Homebrew:

brew install uv

2. Verify Installation:

uv --version

Step 8: Install and Configure Git

Git is a distributed version control system used to track code changes and collaborate with others.
If you don’t have Git installed and configured yet, follow these steps:

# 1. Check whether Git is already installed
git --version

If you see output such as git version 2.45.1, Git is already installed. If not, install it:

# 2. Install Git via Homebrew
brew install git

Set your global username and email address (used for all repositories on this machine):

git config --global user.name "Your Full Name"
git config --global user.email "your.email@example.com"

You can verify your settings:

git config --global --list

Set up SSH for Git (Hub / Lab / Bitbucket) since using SSH keys avoids typing your password every time you push or pull.

# Generate a new SSH key (press Enter to accept the default path)
ssh-keygen -t ed25519 -C "your.email@example.com"
# Start the SSH agent
eval "$(ssh-agent -s)"
# Add your new key to the SSH agent
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
# Copy your public key to the clipboard
pbcopy < ~/.ssh/id_ed25519.pub

Then paste the key into your GitHub / GitLab account under
Settings → SSH and GPG keys → New SSH key.

To test the SSH connection, run:

ssh -T git@github.com

You should see a message like:

“Hi <username>! You’ve successfully authenticated…”

Step 10: Install Docker Desktop for Mac

Docker allows you to run containerized applications.

1. Download Docker Desktop: Visit the Docker Desktop download page and download the macOS version.

2. Install Docker Desktop:

3. Verify Installation:

docker run hello-world
  1. You should see a “Hello from Docker!” message.

Step 12: Install kubectl

kubectl is the Kubernetes command-line tool.

1. Install via Homebrew:

brew install kubectl

2. Verify Installation:

kubectl version --client

That’s It!

With these steps, you now have a fully functional Python programming environment on your macOS machine. Happy coding!

Additional Tips:

Feedback and Contributions:

If you have suggestions or additional tools that enhance the programming environment, feel free to share.