Skip to main content
mattmakesmaps

Python Dev Setup on Mac | Gotchas Documented

Tool Installation #

Here are some personal notes on getting Python setup for my new Mac.

Python Base Install #

At this point, you can use python3 and pip3 commands, but for pipenv you'll need to symlink pip and python.

To do this, note the caveat message produced by brew install python:

Python has been installed as
  /opt/homebrew/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /opt/homebrew/opt/python@3.11/libexec/bin

We need to add the following to the end our ~/.zshrc file (Per this SO Post):

# point python to python3
path+=('/opt/homebrew/opt/python@3.11/libexec/bin')
export PATH

Pipenv #

Get pipenv setup to manage dependencies and virtual environments. Reference Hitchiker's Guide to Python

NOTE: The link above contains a previous section on Python base install. These instructions didn't address symlinking python to python3. Instead of using these, follow notes in Python Base Install section above.

VS Code #

Project Setup #

Python Environment With Pipenv #

Visual Studio Code Launch Configuration #

The following is an example script launch configuration. Note the relative path to the script file in program and the command line args in args.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "mp3-convert.py with test args",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/mp3-convert/mp3-convert.py",
            "console": "integratedTerminal",
            "justMyCode": true,
            "args": [
                "${workspaceFolder}/test_data/source",
                "${workspaceFolder}/test_data/dest"
            ]
        }
    ]
}