QGIS Plugins [Part 4]

Mostafa Farrag
Hydroinformatics
Published in
4 min readOct 20, 2022

--

Sentinel-2 image from google earth engine loaded in QGIS using the Google earth engine data catalog plugin

QGIS Plugins is one of the main features that extends the functionality of QGIS to a great level, However, installing some of these plugins does not always succeed because of dependency issues. In this article, I show you how to locate the default python environment backend used by QGIS, how to install any package there so you can use it in the python console of QGIS, and most importantly to solve the missing dependencies that are needed by a plugin you want to use.

from the Plugins drop-down menu select “Manage and install Plugins..”

Search for the plugin you want, let's say you need a “Google earth engine Data Catalog” plugin, type it in the search field and press “Install Plugin” at the bottom right of the window

In most cases, the installation does not finish successfully because of a missing dependency like here, it failed because the main package of earth engine (ee) is missing, so we need to install it manually

Now comes the main question, Where is the default python environment that QGIS uses installed? to find out the answer, open the python console from the same “Plugins” drop-down menu then choose Python console, or use the keyboard shortcut CTRL+Alt+P. In the console type the following commands and press enter after each line

import sys

sys.executable

The previous command “sys.executable” prints the directory where the system executables exist, and that is where the default python is also installed.

Now open a command prompt and browse to the directory above, if there are spaces in the directory you have to enclose the path between double quotes

cd “C:\Program Files\QGIS 3.24.0\bin”

then type “python” and press enter, and import the missing package you have seen in the error message above to make sure that this is the same python environment that the Plugins manager uses, and you should get the same error message.

PS C:\Program Files\QGIS 3.24.0\bin> python
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:51:29) [MSC v.1929 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import ee
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
ModuleNotFoundError: No module named ‘ee’
>>>

No exit the interpreter using the command

exit()

Now we can actually use this python interpreter in any IDE and install any package we want, but it is better to separate your developing environment from the QGIS environment as installing too many packages might break the installation and you then need to reinstall QGIS or uninstall all of your packages.

We will use pip to install our missing package earthengine-api, to do so type

python -m pip install earthengine-api

The installation might take some time till it finishes

PS C:\Program Files\QGIS 3.24.0\bin> python -m pip install earthengine-api
Defaulting to user installation because normal site-packages is not writeable
Collecting earthengine-api
Downloading earthengine-api-0.1.328.tar.gz (243 kB)━━━ 243.4/243.4 kB 1.9 MB/s eta 0:00:00

.

.

.

Successfully built earthengine-api

PS C:\Program Files\QGIS 3.24.0\bin>

Now you can go back to the Plugins manager and install the “Google earth engine Data Catalog” plugin again, now it should install successfully, however, if it complains again because of any other missing packages, you how to install them.

The installed plugins will be listed in the same drop-down menu “Plugins ” below “Python Console”, we can check now the plugin we just installed

Now we can check all the available datasets in the google earth engine, we can choose Sentinel-2 with true colors, choose any time window, and cloud coverage then press ok (to check the details about the Sentinel-2 dataset in the google earth engine you can check it here)

It might take some time to load the images, if there are no images you can raise the cloud coverage percentage or change the time window, at the end some images will be loaded to your QGIS canvas, and you can toggle them from the layers panel.

Now you can follow the same steps with your computer, regardless you are using Windows, Linux or macOS, and install any plugin.

--

--