Python on Mac
Using the latest deep learning technology means using more Python.
As a frequent user of Node.JS, I find when I dive back into Python, I need a refresher on how it all works on Mac. Here's my quick getting started guide.
Install w/ Homebrew
$ brew install python@3.11
Update alias
This allows you to use the python
command to run Python 3.
# ~/.zshrc
alias python=python3
Setup environment
Environment management keeps your project dependencies isolated from each other.
# Move to a project folder
$ cd ~/projects/my-project
# Create an environment
$ python -m venv env
# Activate the environment
$ source env/bin/activate
Confirm that the python command is now pointing to the correct environment.
$ type -a python
# python is an alias for python3
# python is /Users/username/projects/my-project/env/bin/python
Install packages and save to requirements.txt
$ pip install some-package && pip freeze > requirements.txt
Install from requirements
$ pip install -r requirements.txt
© Mike Surowiec