28

Kyngchaos installer is not finding python3. I installed python3 using HomeBrew and is not located at /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/bin/python3.6

How do I tell the QGIS installer to recognize that python3 is installed?

I had previously installed GDAL using HomeBrew, so tried reinstalling (or installing another version wherever it might end up) thinking it might help with the situation, but the QGIS3 installer still can't find python 3.

The installation error is a popup that comes up as soon as the installer is open and says "python3 QGIS requires Python 3.6."

For non Mac users, most seem to rely on Kyngchaos to provide an installer for QGIS and he has just released the installer for v3.

Update: answered my own questions below. Don't use HomeBrew unless you know enough to point the QGIS installer/QGIS to the right version (which I certainly don't), but use the python3 installer version linked to in the ReadMe.

  • Where are the Kyngchaos installers? I can't find them anywhere. – Alex Leith Mar 11 '18 at 22:18
  • Since he hasn't updated the link, I guessed it to be kyngchaos.com/files/software/qgis/QGIS-3.0.0-1.dmg – Greg Mar 11 '18 at 22:23
  • It's not promoted on his webpage yet is it? – Alex Leith Mar 11 '18 at 22:49
  • 2
    "QGIS 2.18.15-4" is repeated twice at kyngchaos.com/software/qgis and the first should be "QGIS-3.0.0-1". I think it's a copy and paste error, in other words he copied the old link etc and forgot to update. How would I guess this—not because I've ever done it! – Greg Mar 11 '18 at 22:58
  • 4
    Today (12 Mar 2019), the link at kyngchaos.com/software/qgis is updated. – Greg Mar 12 '18 at 18:47
32

NEW UPDATE

QGIS3 can now be installed from osgeo's homebrew tap, which saves mucking about with python symlinks... i.e.

brew tap osgeo/osgeo4mac
brew install qgis

Then type qgis in the terminal to launch, then pin the dock menu icon to simplify launching in future.

Note that the installation console logs will also provide an example for how to symlink qgis to your applications directory.

OLD UPDATE

(This method requires updating symlinks when versions change... i.e. not ideal)

For those who use homebrew, it is probably better to just use a symlink, otherwise all kinds of havoc could emerge. e.g. the official python binary will modify your ~./bash_profile so that python3 and pip3 no longer point to brew...

In my case I've now symlinked the homebrew version (along the lines of the discussion in the answer provided by @Evenfire):

sudo ln -s /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework /Library/Frameworks/Python.framework

QGIS3 then complained that certain python packages were missing, which can be installed with pip3, e.g.

pip3 install owslib PyYaml psycopg2 jinja2 pygments plotly

It might also complain about gdal, in my case I simply used brew:

brew install gdal

ORIGINAL

(This method is not recommended for brew users!)

I've also got python3 installed via brew and am running into the same difficulty.

What seems to work is to install the official python binaries which install to /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.

From trial and error, this has to be done before the 1 Install GDAL Complete.pkg package is installed, which otherwise installs against the wrong python and QGIS 3 will complain about missing python packages.

Those with time to experiment could conceivably try symlinks to get around directly using the brew (or other) python3.

  • Thanks! The install of python just before the "1 Install GDAL Complete.pkg" did the trick for me and solved the error "module osgeo not found". – Javier Fajardo Mar 13 '18 at 18:35
  • Do you have GDAL also installed with homebrew? I created the symlink for python but the installer is asking for GDAL2.2 which I have installed with homebrew. – Duccio A May 18 '18 at 10:32
  • In my case I don't have gdal installed with homebrew. My understanding is that QGIS specifically depends on KyngChaos' version (unfortunately!). So it might be necessary to install the gdal provided with QGIS and then it might work. – songololo May 18 '18 at 13:26
  • 1
    I noticed that installing binaries for the newer python3.7 is not supported by the newest QGIS installer! python3.6.6 is necessary, and it can be downloaded from the link that you provided in this answer. – Javier Fajardo Jul 18 '18 at 15:06
  • 2
    This might be a very stupid question, but once you've installed qgis via homebrew, how do you run it? Figured it out: qgis3 is the command. – Juan Francisco Saldarriaga Aug 20 '18 at 17:13
28

If you have installed Python3 with Homebrew, you can use symlinks to comply with the installer needs (as suggested by @shongololo).

It seems, the installer needs Python3 installed at (thanks @shongololo): /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.

(Install python3 using Homebrew to follow this part)

Find the Cellar directory on your machine. Mine is at: /usr/local/Cellar. Then find this directory: /usr/local/Cellar/python3/3.x.y_z/Frameworks/Python.framework (where 3.x.y_z is the python3 version you want to use, for me it is 3.6.4_2). This is the directory we want the installer to find. We need to link to this directory from the directory the installer is looking at by making a Symbolic Link.

Using the ln command (ln -s TARGET_FILE_TO_LINK_TO LINK_NAME): ln -s /usr/local/Cellar/python3/3.x.y_z/Frameworks/Python.framework /Library/Frameworks/Python.framework will do the trick. You certainly need to sudo.

This has worked for me.

(The "Cellar" is a place that all your "kegs" go. Homebrew installs packages to their own directory (in the Cellar) and then symlinks their files into /usr/local/. [from Ryan Kulla's blog])

  • Thanks for this info. I fixed already with "default" installer. Since I don't need Python for anything else that will work for me. I in general prefer to use Homebrew for consistency. And Apple has v2 installed by default. Was are the tradeoffs between using the two installers (Homebrew and one from the python site)? I guess that Homebrew will keep python updated more easily. And you can uninstall easily. I have no idea how to do that with the other install method. Got me thinking to go back to the Homebrew version since I know how to manage it. – Greg Mar 13 '18 at 19:59
  • @greg homebrew is easier to much easier to manage, e.g. uninstalls. It also keeps your various package interdependencies interlinked quite nicely. – songololo Mar 14 '18 at 9:34
  • 1
    @evenfire thanks for the nice explanation. brew info python is a handy way to quickly find paths to existing brewed python installs – songololo Mar 14 '18 at 9:36
  • 4
    A heads-up that brew recently changed their default python to v3, so for those that have recently updated / upgraded their homebrew, the above paths would contain python and not python3 – songololo Mar 14 '18 at 10:13
  • 4
    How could I connect the framework file with anaconda python? (I cannot find python.framework in anaconda dirs) – natsuapo Mar 15 '18 at 14:16
5

I followed the link that came with the QGIS installer to https://www.python.org/downloads/ and installed python3 that way. The QGIS installer was then happy.

This seems to be contradicted by comments here:

"Because QGIS links the python library, you must install the python.org Python 3.6. You can't substitute another python 3 installation. Sorry, that's the way it is."

Posted at http://www.kyngchaos.com/blog/2018/20180315_qgis_3_must_use_python.org_python_3. If I knew how to contact William Kyngesbury, I would. He is performing a great service though.

3

A version using pyenv and brew:

brew install pyenv
env PYTHON_CONFIGURE_OPTS="--enable-framework CC=clang" pyenv install 3.6.5
sudo ln -s /Users/$USER/.pyenv/versions/3.6.5/Python.framework/Versions/3.6 /Library/Frameworks/Python.framework/Versions/3.6
sudo cp -R /Users/$USER/.pyenv/versions/3.6.5/Python.framework/Versions/3.6 /Library/Frameworks/Python.framework/Versions/3.6
sudo cp -r /Users/$USER/.pyenv/versions/3.6.5/lib/python3.6/lib-dynload/ /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload
sudo cp /Users/$USER/.pyenv/versions/3.6.5/lib/python3.6/lib-dynload/_struct.cpython-36m-darwin.so /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload/_struct.cpython-36m-darwin.so
# 
  • 2
    it should be enough just to run first 2 lines and then ln -s ~/.pyenv/versions/3.6.5/Python.framework /Library/Frameworks/Python.framework – Alex Markov Jul 4 '18 at 8:53
2

Another version of pyenv and symlinking, using brew just for dependencies.

Recommended location to install pyenv is ~/.pyenv ($HOME/.pyenv), but could be any location.

  1. clone pyenv repository (maybe adapt ~/.pyenv to /path/to/pyenv)

    git clone https://github.com/pyenv/pyenv.git ~/.pyenv
    
  2. setup pyenv in ~/.bash_profile (maybe adapt $HOME/.pyenv to /path/to/pyenv, be aware, that the third line must stay the final one of .bash_profile, even after future updates)

    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
    echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
    echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
    
  3. restart shell

    exec "$SHELL"
    
  4. install dependencies readline and xz the easy way with brew

    brew install readline xz
    
  5. install Python 3.6.x containing Python.framework (maybe adapt version number)

    env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.6.8
    
  6. always rehash after adding a new Python version to pyenv

    pyenv rehash
    
  7. symlink Python.framework

    sudo ln -s $(pyenv root)/versions/3.6.8/Python.framework /Library/Frameworks/Python.framework
    

Now the QGIS 3.6.0 installer from qgis.org should run fine plus macOS is well prepared for multiple Python versions, playing nice with system's Python.

0

I faced the same issue when installing QGIS on mac.
It was failed, although I tried to softlink it with other python installed by anaconda, etc.
The way I solved the issue: download related python version in python.org and install.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.