Image for post
Image for post

Managing Python on macOS Big Sur

When Apple releases a new version of macOS it always takes a few months for everything to catchup, following my last blog post where I mentioned that I was which meant that my preferred method of installing and managing Python using pyenv, which is , didn't work out of the box — and the workarounds suggested workarounds on GitHub made my shell really slow.

Luckily, I noticed that there was an update to both andpyenv when I ran brew update today so decided to give pyenv another try, and it worked as expected.

First I manually installed some prerequisites suggested on various GitHub issues, just to be on the safe side:

$ brew install zlib sqlite bzip2 libiconv libzip

Next up you can either install or upgrade to the latest version of pyenv, which during writing is 1.2.22:

$ brew install pyenv

If like me, you need to upgrade, then you can run:

$ brew upgrade pyenv

Once the latest version pyenv has been installed, run the following commands to install the latest stable version of Python, which is currently 3.9.1:

$ pyenv install 3.9.1
$ pyenv global 3.9.1
$ pyenv version

Once installed, run the following command to make sure that the pyenv managed version of Python is picked up:

$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\\n eval "$(pyenv init -)"\\nfi' >> ~/.zshrc

Open a new shell and run:

$ python --version
$ which python

This should return something like the following:

Image for post
Image for post
Checking the version of Python and its part

The final step is to make sure that pip is up-to-date, to do this run:

$ pip install --upgrade pip

This fixed a few issues I had when I ran:

$ pip install --user ansible

Geek, Lover Of Shiny Things and Grump.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store