takarajapaneseramen.com

Essential MacBook Configuration for Aspiring Programmers

Written on

Setting Up Your MacBook: A Beginner's Guide

Getting your MacBook ready for programming might feel overwhelming, but with the right approach, it can be quite straightforward. This guide is tailored for beginners to help you on your journey.

Table of Contents

  1. Terminal Configuration

    — iTerm

    — Oh My Zsh

  2. Code Editors

    — PyCharm or VSCode

    — Selecting a Docstring Style

  3. Python Environment Setup

    — Installing Homebrew

    — Setting Up Pyenv

    — Utilizing Pipenv

  4. Git Hooks

    — Installing pre-commit

    — Sample .pre-commit-config.yaml

    — Configuring Git Hooks

  5. Managing Databases

    — Installing TablePlus

  6. Docker Setup

    — Installing Docker Desktop

    — Using Docker and Docker Compose with Homebrew

Terminal Configuration

iTerm: Begin by installing iTerm and setting it as your default terminal for an enhanced coding experience. Go to iTerm2 > Make iTerm2 Default Term.

Oh My Zsh: Improve your terminal's functionality by adding Oh My Zsh. You can customize the theme; I recommend the "candy" theme for its vibrant aesthetic.

Code Editors

Select either PyCharm or VSCode as your code editor—both are fantastic options for newcomers.

Note: The community edition of PyCharm is free and should suffice for most needs. Additionally, pick a docstring style, such as numpy, to maintain consistency in your code documentation.

Python Environment Setup

It’s advisable to avoid using the default Python version on macOS for development, as it may lead to system conflicts and lacks version control. Instead, utilize three essential tools for managing Python environments:

  1. Homebrew: This is a package manager for macOS. You can install it by following the instructions on their official site.

  2. Pyenv: This tool helps you manage multiple Python versions. After installing Homebrew, run these commands:

    brew install pyenv

    To configure your shell environment for Pyenv, add these lines to your .zshrc file (make sure to verify with the official documentation for any updates):

    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc

    echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc

    echo 'eval "$(pyenv init -)"' >> ~/.zshrc

    Verify successful setup by checking the contents of your .zshrc file:

    cat ~/.zshrc

    To view available Python versions, run:

    pyenv install --list

    To install a specific Python version, use:

    pyenv install <version-number>

    For instance:

    pyenv install 3.12.2

    If you encounter a ModuleNotFoundError related to _lzma, install the necessary library:

    brew install xz

    To uninstall an installed version:

    pyenv uninstall 3.12.2

    You can check all installed versions with:

    pyenv versions

    The output may look something like this:

    -> % pyenv versions

    • system (set by /Users/najmabader/.pyenv/version)

      3.12.2

    The asterisk (*) denotes the global Python version. To switch to the newly installed version, execute:

    pyenv global 3.12.2

    Understanding Global vs. Local Versions: In Pyenv, global and local versions determine how Python versions are selected in different contexts. The global version is the default across your system, while the local version pertains to a specific project or directory.

    Quick Summary: Set a global Python version as your default, but remember you can specify a local version for individual projects.

    pyenv global 3.12.2

    pyenv local 3.12.23

  3. Pipenv: This tool streamlines package management by creating virtual environments. Install it with:

    pip install pipenv

    To ensure Pipenv uses the active Python version from Pyenv, add this line to your .zshrc file:

    echo 'export PIPENV_PYTHON="$(pyenv root)/shims/python"' >> ~/.zshrc

    Set your default language:

    echo 'export LANG="en_US.UTF-8"' >> ~/.zshrc

    echo 'export LC_ALL="en_US.UTF-8"' >> ~/.zshrc

    echo 'export LC_CTYPE="en_US.UTF-8"' >> ~/.zshrc

    To create a new virtual environment for projects, navigate to the project directory and run:

    pipenv install

    This will result in:

    Virtual Environment Creation

    If you require a specific Python version, do the following:

    pyenv versions

    cd Projects/test2

    pyenv local 3.8.18

    pip install pipenv

    For existing projects, navigate to the directory and execute:

    pipenv install --dev # for development packages

    pipenv install # for production packages

    pipenv run pip list # to view installed packages

    pipenv shell # to activate the environment

    pipenv deactivate # to exit the environment

Git Hooks

Git Hooks are vital for ensuring code quality. To install pre-commit, run:

pipenv install pre-commit

Define your hooks in a .pre-commit-config.yaml file. An example configuration might look like this:

repos:

rev: stable

hooks:

  • id: black

    language_version: python3.12.2

rev: 5.12.0

hooks:

  • id: isort

    exclude:

    name: isort

    language_version: python3.12.2

Navigate to your project directory in the terminal and run:

pre-commit install # to activate your Git hooks

pre-commit run --all-files # to test your commits

Managing Databases

Consider installing a database management tool like TablePlus to simplify database handling.

Docker Setup

Docker is crucial for running containers on your Mac. Start by installing Docker Desktop and then execute the following commands in your terminal:

brew install docker

brew install docker-compose

If you have an Apple Chip, you may need to add this line to your .zshrc:

echo 'export DOCKER_DEFAULT_PLATFORM=linux/amd64' >> ~/.zshrc

With this configuration, you're all set to start your coding journey on your MacBook! Enjoy coding!

The first video provides a comprehensive overview of how to set up your MacBook Pro specifically for programming, making the process easier for beginners.

In this second video, discover a minimalist coding desk setup designed for maximum productivity, perfect for those looking to optimize their workspace.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

Harnessing Solar Energy: The Future of On-Demand Electricity

Discover how molecular solar thermal energy storage can revolutionize electricity generation from stored solar heat.

Lessons Gained by the Time You Turn 30

Reflecting on 11 key insights learned before turning 30.

How to Transform Unpleasant Tasks into Gratitude Opportunities

Discover how rephrasing tasks can shift your perspective and foster gratitude for daily responsibilities.

Unlocking Longevity: The Power of Mindset on Aging

Explore how a positive mindset can significantly impact longevity and change your perceptions about aging.

# Overcoming Toxic Productivity Habits for Better Efficiency

Explore the pitfalls of switching productivity apps and discover strategies for long-term success.

# The Irony of Self-Help: Are We Improving or Just Chasing Shadows?

A humorous exploration of the self-help obsession and its irony in modern society.

Understanding the Hidden Reasons Behind Our Suffering

An exploration of why individuals may choose to endure suffering despite the possibility of change.

A Hilarious Prank by an Astronaut on the International Space Station

Discover the amusing tale of astronaut Scott Kelly's gorilla suit prank aboard the ISS, bringing laughter to the cosmos.