Install Python 3 Macos Catalina


I'm still working on getting pyenv in my bloodstream. It seems like totally the right tool for having different versions of Python available on macOS that don't suddenly break when you run brew upgrade periodically. But every thing I tried failed with an error similar to this:

I read through the Troubleshooting FAQ and the 'Common build problems' documentation. xcode was up to date and I had all the related brew packages upgraded. Nothing seemed to work.

Until I saw this comment on an open pyenv issue: 'Unable to install any Python version on MacOS'

See the Python for Mac OS X page. MacOS from 10.2 (Jaguar) to 10.15 (Catalina) includes a system version of Python 2, but it is best not to consider this the Python to use for your programming tasks - install a current Python 3.x version instead. MacOS after 10.15 (Catalina) will not include a default system Python. It is the successor to macOS Mojave and was announced at WWDC 2019 on June 3, 2019 and released to the public on October 7, 2019. MacOS from 10.2 (Jaguar) to 10.15 (Catalina) includes a system version of Python 2, but it is best not to consider this the Python to use for your programming tasks - install a current Python 3.x version instead. Historically MacOS came preinstalled with Python 2, however starting with macOS Catalina 10.15 (released in October 2019) this is no longer the case. And since Python 2 will no longer be officially supported as of January 1, 2020, you should really use Python 3 instead. There are multiple ways to install Python 3 on a MacOS computer.

All I had to do was replace the 10.14 for 10.15 and now it finally worked here on Catalina 10.15. So, the magical line was this:

Hopefully, by blogging about it you'll find this from Googling and I'll remember the next time I need it because it did eat 2 hours of precious evening coding time.

Related posts

Install Python 3 Mac Os Catalina Download

redirect-chain - Getting a comfortable insight input URL redirects history14 February 2020
How to install Node 12 on Ubuntu (Eoan Ermine) 19.1008 April 2020
Related by category:
Best practice with retries with requests19 April 2017Python
How much faster is Redis at storing a blob of JSON compared to PostgreSQL?28 September 2019Python
Fastest way to find out if a file exists in S3 (with boto3)16 June 2017Python
Interesting float/int casting in Python25 April 2006Python
Fastest way to unzip a zip file in Python31 January 2018Python

Pip broken under Mac OS X Catalina? TLDR;

pip install --global-option=build_ext --global-option='-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/' --global-option='-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/' --prefer-binary -r requirements.txt

As Apple has announced, Mac OS Catalina now runs under its own read only file system:

macOS Catalina runs on a dedicated, read-only system volume called Macintosh HD. This volume is completely separate from all other data to help prevent the accidental overwriting of critical operating system files. [1]

Sounds great. But if you need to change that volume, or if you use software that expects to be able to find files on that read only volume that aren't there and can't be added, you're kind of stuck.

One example is Python's pip which, for some packages, will expect to find header files located in /usr/include. Apple gave developers a get-out-of-jail-free card in Mojave:

As a workaround, an extra package is provided which will install the headers to the base system. In a future release, this package will no longer be provided. [2]


Install Python 3 Mac Os Catalina Os

Install python 3 mac os catalina os

and in true Apple fashion, the package was taken away. This creates problems if you want to install commonly used, but maybe not so commonly maintained, libraries. One example is Pillow, an image processing library. This will well and truly fail to compile if you just try pip install Pillow. It looks for the headers and libraries, and doesn't find them.

What can we do? Well, for pip there's a few options. The first is simply not to compile at all, but to prefer a binary. This is as simple in some cases as the --prefer-binary option. But what if, like Pillow, there is no precompiled binary for your platform? Or for reasons of information security, you have to compile it yourself?

Fortunately, pip can be directed to look in different places using the 'global-options' flag. To get Pillow to build, use the command at the top of this article, reproduced below:

Install Python 3 Mac Os Catalina Update

pip install --global-option=build_ext --global-option='-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/' --global-option='-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/' --prefer-binary -r requirements.txt

To understand this more fully, take a look at

Install Python3 Macos Catalina

If you need to do a similar function as part of other install tools, common environment variables are LD_LIBRARY_PATH (deprecated[3], but still commonly used), LIBRARY_PATH and INCLUDE_PATH. Setting these to the library paths (/Library ... /usr/lib) and include paths (/Library ... /usr/include) respectively may help.

Install Python3 Macos Catalina