Install plpython on mac with python 2.7

(macOS Catalina 10.15.5, Homebrew 2.3.0)

The voted solution does not work with recent versions of Homebrew, which does not support options anymore, see https://github.com/Homebrew/homebrew-core/issues/31510.

> brew reinstall [email protected] --with-python
...
Error: invalid option: --with-python

Fortunately, there is petere / homebrew-postgresql

I first updated the XCode command tools, in order to avoid this error:

configure: error: header file <perl.h> is required for Perl

with

> sudo rm -rf /Library/Developer/CommandLineTools
> sudo xcode-select --install

And then

> brew tap petere/postgresql
> brew reinstall petere/postgresql/[email protected]

brought plpython2 back to life for me.


If anybody has the same problem, I fixed this by uninstalling postgres and installing it using brew install postgres --with-python


Ugh, this was a real pain as they have removed the with-python@2 option. I managed to get it installed with the following steps:

git clone https://github.com/Homebrew/homebrew-core.git
cd homebrew-core/
git checkout c2c0659f5a2e5be9c54c214e5aa19a2fe2cdc374
brew install --build-from-source ./Formula/[email protected] --with-python@2
brew services restart [email protected]

Probably there is a better way but this worked for me.


I quickly create a tap formula for the latest postgresql (11.2), add a --with-python option to compile options. So far it's work. No binary version, only compile from source. To use it:

brew tap indlin/postgresql-py
brew install postgresql-py

If I understand correctly, this is the official path for change options in brew (create your own tap formula). I don't understand why they do it???