Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mfonism/663274fff899598ecb849fdcfb378bce to your computer and use it in GitHub Desktop.
Save mfonism/663274fff899598ecb849fdcfb378bce to your computer and use it in GitHub Desktop.

Preparing for Today's Class - Python Installation & Update (Mac OS only)

Hey everyone,

To get ready for today’s class, we all need to have the latest version of Python installed. Follow these steps carefully to ensure you’re all set. We’ll first check if you already have Python installed, and then branch out based on what we find.

Note: Whenever we say "terminal" or "your terminal" in these instructions, we’re referring to iTerm2.

1. Open Your Terminal (iTerm2)

  • Make sure you have your terminal (iTerm2) open. If not, launch it now.

2. Check if You Have Python Installed

  • In your terminal, type the following command and press Enter:

    python3 --version
  • If you see a version number like Python 3.x.x, it means you have Python installed. Proceed to the Update Existing Python section.

  • If you see a message saying command not found or something similar, it means Python is not installed. Proceed to the Install Python section.

Branches: Updating Existing Python || Installing Python

Please follow the instructions based on whether you already have Python installed or not. Do not run both branches; just stick to the one that applies to your situation.

Branch 1: Update Existing Python

If you already have Python installed:

  1. Update Homebrew: Make sure Homebrew is up to date by running:

    brew update
  2. Upgrade Python: To upgrade your existing Python installation to the latest version, run:

    brew upgrade python
  3. Verify the Update: After the upgrade, check the version again to ensure it's the latest:

    python3 --version

    You should see something like Python 3.x.x, where x.x is the latest version number.

  4. Optional - Brave Souls Only:
    Notice: This step is optional. If you want to set an alias so that python points to python3, you can do so with the following command. If this seems complicated, feel free to skip it! We’ll go over it in class.

    echo 'alias python=python3' >> ~/.zshrc
    source ~/.zshrc
  5. You're All Set!

    • You’re now ready for class. Take note of your Python version and share it with me.
    • Also, visit Python’s download page to check the latest version available and compare it with yours.

Branch 2: Install Python

If you don’t have Python installed:

  1. Install Python:

    • After Homebrew is installed, run:
      brew install python
  2. Verify the Installation: Once the installation is done, check the Python version:

    python3 --version

    You should see something like Python 3.x.x, confirming that you have the latest version.

  3. Optional - Brave Souls Only:
    Notice: This step is optional. If you want to set an alias so that python points to python3, you can do so with the following command. If you’re not sure about this, it’s okay to skip it for now. We’ll cover it in class.

    echo 'alias python=python3' >> ~/.zshrc
    source ~/.zshrc
  4. You're All Set!

    • You’re now ready for class. Take note of your Python version and share it with me.
    • Also, visit Python’s download page to check the latest version available and compare it with yours.

Looking forward to seeing everyone ready with the latest Python version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment