Correctly Install Python on MacOS #

Last updated March 17, 2026
macospythoncircuitpython

Python on Mac is a pain because there are so many different ways to do it. I've found that pyenv is the best way to manage python versions on MacOS

# install pyenv
brew install pyenv pyenv-virtualenv

# list all available python variants
pyenv install -l

# install latest 3.x.x python
pyenv install 3 

# add to the shell
echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc

Now restart your shell / open a new terminal window.

You can manage python with these commands:

  • See the current global version: pyenv versions
  • See where the current python versions come from: pyenv versions
  • See what is the current local version: pyenv local
  • List all possible versions of python to install pyenv install --list
  • Install (download and build) a particular version of python pyenv install 3.12.8
  • Set the current local version to 3.12.8: pyenv local 3.12.8

Audio conversion #

Last updated March 16, 2026
macos

To convert between audio files first install ffmpeg with brew install ffmpeg.

Convert wav file to mp3. the 320k is the bitrate. For smaller files try 128k.

ffmpeg -i input.wav -codec:a libmp3lame -b:a 320k output.mp3

Fix SDCards and disks #

Last updated March 16, 2026
macos

Sometimes you need to reformat a disk and DiskUtility isn't cutting it. I had a recent case of an SD card I'd used to install Linux. Disk Utility could see the drive but not read the linux partitions nor erase the partitions to turn it back into a plain MS-Dos (FAT) drive. The key is to use diskutil, the command line counterpart.

List the partitions

diskutil list

Find the id for the disk you are erasing. disk4 in my case.

diskutil eraseDisk FAT32 RASPBIAN MBRFormat disk4

Adjust system settings from the command line #

Last updated March 16, 2026
macos

Settings can be configured with the defaults command and the key representing that particular setting. See macOS defaults for more info.

ex:

# read the current orientation
defaults read com.apple.dock "orientation"
# position the dock on the left side of the screen
defaults write com.apple.dock "orientation" -string "left"
# restart the Dock
killall Dock 

set the default location for screenshots

# set to ~/Desktop
defaults write com.apple.screencapture "location" -string "~/Documents/Screenshots"
# restart system ui server
killall SystemUIServer

Remote access for local development #

Last updated March 16, 2026
macos

Suppose you are developing a web app on your laptop and you want your phone to test it. Getting your phone to talk to the local webserver can be tricky depending on the local network environment. Instead use an SSH tunnel to expose a single port of your laptop as a port on a remote webserver. This is called an SSH tunnel. Assuming you already have ssh locally and a linux remote webserver.

Check the /etc/ssh/sshd_config file on your server has these turned on

AllowTcpForwarding yes
GatewayPorts yes

and restart the ssh server if necessary with sudo systemctl restart ssh.

Then on your local computer set up the tunnel with

ssh -R <remoteport>:localhost:<localport> username@server.com

For example:

ssh -R 6000:localhost:4000 me@example.com

The local webserver is on 4000. Connect to it from http://example.com:6000/.

If you are using vite you access may be blocked for security reasons. Turn on allowed hosts in your vite config file.

  server: {
    allowedHosts:['josh.earth']
  }

Cleanup unused applications #

Last updated March 16, 2026
macos

brew install pearcleaner then run Pearcleaner.app.

Install Brew and other tools #

Last updated March 16, 2026
macos

Copy the script from here and paste into the terminal.

brew doctor
brew install nodejs

MacOS Screenshots #

Last updated March 16, 2026
macos
  • screen capture: command-shift-5
  • Choose window and mode
  • Click to take the screenshot
  • Control-click to put it into the clipboard instead of on disk
  • Option-click to not show the window drop shadows
  • Option-control-click to put into the clipboard and not show window drop shadows