macOS and Python
TL;DR: Installation Instructions
macOS includes Python because the operating system needs it. If you want to manage your own Python packages and versions, do not rely on the system Python.
Many guides suggest Homebrew for Python. That is convenient, but it is still not ideal for project-pinned Python versions. Homebrew Python mainly exists to support Homebrew packages.
Homebrew also removes old package versions over time. For example, you might need Python 3.10 for SD.Next while using 3.12 elsewhere. Homebrew can remove 3.10 because it does not track your SD.Next dependency.
Use a dedicated version manager for user-managed Python installs. This guide uses asdf with the Python plugin, but equivalent tools are fine.
Sources / Further reading: - https://justinmayer.com/posts/homebrew-python-is-not-for-you/ - https://hackercodex.com/guide/python-development-environment-on-mac-osx/ - https://github.com/asdf-community/asdf-python - https://asdf-vm.com/ - https://docs.brew.sh/Installation
Installation Instructions
- If you haven't got Homebrew installed already:
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip-components 1 -C homebrew
eval "$(homebrew/bin/brew shellenv)"
brew update --force --quiet
chmod -R go-w "$(brew --prefix)/share/zsh"
- Install asdf and python build dependencies:
brew install asdf openssl readline sqlite3 xz zlib
- Add asdf to
.zshrcto use it immediately and persistently:
. $(brew --prefix asdf)/asdf.sh
echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ~/.zshrc
- Add the python asdf plugin:
asdf plugin add python
# for SD.Next
asdf install python 3.10.14
# you may want the latest version too; take note of which version is installed
asdf install python latest
- Set the default global version of python:
Since SD.Next needs 3.10, call that version explicitly for SD.Next. For general use, keep your preferred default Python version.
asdf global python 3.12.2
# or whatever version you installed
- Run SD.Next using python3.10:
export PYTHON=$(which python3.10)
cd /path/to/SD.Next
./webui.sh --debug