How to quickly install Python on a Mac
December 28, 2020 - 2 min read
Use this bash three-liner for installing a minimal Python 3 distribution (Miniconda) anywhere you need an up to date Python distribution on a Mac.
After trying various installation methods the past few years, Miniconda “just works”, is fast to install and takes little space. It can be installed via the command line on a Mac as per (cli-based installation instructions), eg;
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
conda init
Open a new shell prompt after installing and you are ready to run modern Python software
Next steps
Only one Python version is available “by default” in new terminal windows (eg 3.8). Use the conda
command to install any version of Python 3 (3.7, 3.8, etc) independently of each other.
Eg if you want to run Python 3.9:
conda update -n base -c defaults conda # once, to make sure Python 3.8 is available
conda create -n python39 python=3.9 # once per python version
conda activate python39 # every time you want to access Python 3.8 in a terminal
Note that use of Miniconda/Anaconda does not require you to use conda to install and maintain all packages. Feel free to use venv
“as usual”. Conda is just a clean way of installing Python (and it’s various versions) cleanly on a Mac as per above.