Pages

Python

https://docs.python-guide.org/starting/install3/osx

Setup

  • Need GCC
    • included in Xcode, so install Xcode
      • What's Xcode? Apple says it's developer tools.
      • includes gcc (gnome compiler)
  • Need Homebrew
    • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  • brew install python3
    • Install location: /usr/local/bin
  • python3 to get version 3. python gets version 2.
  • pip3
  • https://opensource.com/article/19/5/python-3-default-mac
    • brew install pipenv
    • pipenv install --list
      • see what's available to install
    • pyenv install 3.12.2

Path Settings

if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
alias python=/opt/homebrew/bin/python3

using pipenv

pipenv has virtual environment management built in so that you have a single tool for your package management.

https://realpython.com/pipenv-guide

Once you’ve done that, you can effectively forget about pip since Pipenv essentially acts as a replacement. It also introduces two new files, the Pipfile (which is meant to replace requirements.txt) and the Pipfile.lock (which enables deterministic builds).

Pipenv uses pip and virtualenv under the hood but simplifies their usage with a single command line interface.

  1. create project folder
    cd project_folder
  2. pipenv install requests
  3. $pipenv shell
    • should see the pipenv name at the beginning of line prompt

direnv

When you cd into a directory containing a .env, direnv automagically activates the environment.

Install it on Mac OS X using brew:

$ brew install direnv

https://docs.python.org/3/using/mac.html