Skip to content

Instantly share code, notes, and snippets.

@tommct
Last active January 9, 2025 02:10
Show Gist options
  • Save tommct/05db3c414b02b3d66f032498d7307186 to your computer and use it in GitHub Desktop.
Save tommct/05db3c414b02b3d66f032498d7307186 to your computer and use it in GitHub Desktop.
Install Python MacOS 14, Pyenv

Taking a new tack, we are going to use UV. This installs a new, global Python environment. It can easily be tweaked for other project and local environments.

Install uv via

curl -LsSf https://astral.sh/uv/install.sh | sh

Make a bash file, install_python.sh:

#!/bin/bash

# This should be in the HOME directory
uv python install 3.12
uv venv
source .venv/bin/activate
# Change packages below as desired
uv pip install -r requirements.txt

Make it executable

chmod +x install_python.sh

Edit .zshrc file, adding

alias venv="source $HOME/.venv/bin/activate"
alias py="source $HOME/.venv/bin/activate; python"
alias jl="source $HOME/.venv/bin/activate; jupyter lab"
alias jn="source $HOME/.venv/bin/activate; jupyter notebook"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment