Install Python 3 on MacOS

The MacOS comes with an old version of Python 2. For new software development Python 3 is the recommended version. Replacing the original Python 2 with Python 3 can cause instability in the MacOS. There are multiple ways to install Python 3 and keep Python 2 pn the Mac. This is the most recommended process:

Use multiple Python versions side-by-side


Pyenv is a Python version manager. It is recommended, because it does not depend on Python, (written in Bash) and using it we can install and utilize multiple Python versions without affecting the Python version used by MacOS.

Check the default Python version

Open a new terminal window fo these configuration changes to take effect

python --version

Use virtual environments


Anaconda (conda) can create a python bubble for you with no preinstalled packages. You can create a Python virtual environment for each of your projects to isolate them and only install the required packages.

Integrate Anaconda with Pyenv

If you use Pyenv to install multiple Python versions side-by-side and installed Anaconda to create virtual environments for each of your projects, install pyenv-virtualenv to integrate them.


During the installation I have encountered the following error messages

Error: The following directories are not writable by your user:

You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/bin

To set you as the owner of the /usr/local/bin directory execute

sudo chown -R $(whoami) /usr/local/bin

homebrew-core is a shallow clone.
To brew update, first run:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch –unshallow

To update the shallow clone of the repository from GitHub execute

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

Error: The following formula cannot be installed from bottle and must be
built from source.
Install the Command Line Tools:
xcode-select –install

To install the xcode command line developer tools execute

xcode-select --install

Leave a comment

Your email address will not be published. Required fields are marked *