⏱reading time: 9 min

Just a couple days ago I was about to write a post about how difficult, or almost impossible, is to install the last versions of QGIS on macOS right now. Everything started, I believe, when gdal package got update at the beginning of the week and that broke my install of QGIS 2 even thought, and to be honest, I really don’t know if all this mess was caused for that update, or by the update of the python formulae in Homebrew. Anyhow, usually these problems are solved just rebuilding the app from source using the new packages, but in this occasion that solution wasn’t working.

Homebrew decided that on the first of March the behavior of the Python formulae and the name, and I believe the name of the formulae, was going to change to be more consistent. To sum a little bit up, after the change python was going to point to python3 in your shell and python2 is going point to so python2 –or something like that. However, the change in the command in the CLI  broke a truckload of third party software, and seems that also wasn’t compliant with Python’s policy. So… they decided to change some things back –CLI commands, no formulae names– and now seems that python ➜ python2 and python3python3. If you are confused, don’t worry, am I also. Besides, since I’m not an expert in the matter and I’ve perhaps missed something in all this chaos. In consequence… I really don’t know!.

Anyhow and right now, with the current state of Homebrew and the OSGeo/homebrew-osgeo4mac tap, it’s quite difficult to install the last versions of QGIS in macOS. A few weeks ago, QGIS released QGIS 3 Girona, however it’s only possible to install it right now in Windows and Linux. Usually on macOS the releases has been a little bit slower than in other platforms basically because QGIS has really few developers able to work on macOS and seems that things aren’t as easy as in other platforms. Traditionally, Homebrew has come to the rescue with OSGeo/homebrew-osgeo4mac tap, which you can build your own version of QGIS, but that repo hasn’t been update almost since the beginning of December. This time the delay not only mean that the macOS users not only can’t install the last small incremental change version, but that for more than 3 weeks we aren’t able to install the last version, which means a big leap from version 2 to 3.

This left the macOS users a little bit hanging although we still can download the official build for macOS in the KyngChaos download page, where you can find the 2.18.14 version. The problem is that version isn’t even the last version of the long-term repository release, which is 2.18.17.

Nevertheless, this weekend I was able to rebuild the last version of the LTR of QGIS 2 and the developer version of QGIS3. I really don’t know how stable is the QGIS 3 developer version, but at least at first sight everything works and the app even open faster than the QGIS 2.

How to install the last version of QGIS 2?

What I did was just reinstall python, python2, gdal, gdal2, and finally qgis2. More or less as follows:

After that and compiling here and there, I was able to open QGIS.app again.

This left me with QGIS in /usr/local/Cellar/qgis2/2.18.14. But I want to have QGIS.app in /Applications folder so I have two options. First one is run in the following command in the terminal, as advised by Homebrew:

However, I prefer to move the actual app to the /Applications folder and create a symbolic link on the /Cellar folder.

Yet, weren’t we going to install the last version of QGIS? This isn’t the last version. OK…

QGIS 2.18.17

To install the last version you need to change the the QGIS formulae to make it to download the last version from the LTR. Since Homebrew isn’t anything more than a git with Ruby scripts I recommend you to make a branch in the repository and change the formula. You aren’t going to change anything in Homebrew, but in a branch of tap, in the OSGeo/homebrew-osgeo4mac tap. I did the following.

First, I create a branch and checked out on it.

Now you can edit the formula to be able to install QGIS 2.18.17. You can see how I modify mine below that has highlighted the lines I’ve changed.

Now you just commit. 

And now you just reinstall QGIS and move to /Applications:

QGIS 2.18.17 splash screen

QGIS 2.18.17 interface


Since /homebrew-science has been deprecated and some of the formulae wasn’t migrated to the /homebrew-core this left us with a message at the end of the QGIS’ compilation asking us to install matplotlib via pip.

I had a problem and when I tried to install using pip install matplotlib threw me an error, though.

Basically I had a ownership problem, that can be solve using sudo.

Or fixing the ownership like this:

Now, I was able to install.

How to install QGIS 3?

Well, this is a little bit more challenging, but just a little bit. The only version of a Homebrew formula that is available to install QGIS 3 is the developer version one that is in this /homebrew-qgisdev repo-tap. So I just have to tap that repo:

However, I needed to make changes in the formula to be able to install because it has a dependency on Matplotlib on /homebrew-science and as we learned before that formula doesn’t exist anymore. In this case, it isn’t like in the QGIS 2, that it builds anyway and then ask you to install Matplotlib. It just doesn’t build and throws an error.

I have two options here. I can just delete or comment the line where the dependency is called, or I can replace it for the legacy formula, which is located in the /homebrew-science tap. Either way I proceeded in the same way as I did previously.

First, I created a branch and edited the formulae.

You can check how I’ve edited mine below. The important part is in the highlighted 86-87 lines.

Then, I just committed my edits 

Before I tried to build I have to do two more tweaks to be able to compile without errors. First I have to reinstall Bison.

And then I have to modify the file /usr/local/bin/pyrcc5 and change pythonw2.7 to python3.

Now I could build QGIS 3 developer edition:

QGIS 3 dev splash screen

QGIS 3 interface

After I finished building the QGIS 3, I moved the app from the Homebrew Cellar to the /Applications folder in the same way I moved QGIS 2, but since I want to keep QGIS 2 and QGIS 3, in the process I renamed the app to QGIS 3.app.

Final thoughts

I hope that in the near future the situation improve and we can enjoy the last version of QGIS on macOS in a easier way. Perhaps even without needed to compile. However, in this very moment isn’t the case.

You have to take into account that with this method you are installing the QGIS 3 developer version, so probably isn’t going to be really stable, or perhaps you are going to have no problem. I guess that you can install the stable version using the QGIS3-dev formulae, you just have to change the values branch =>  to "release-3_0" in line 37 and version to "3.0" on line 38.

Anyhow, I think I’m going to keep the 3.1 version for a while.



Leave a Reply