3

I use the standalone version of QGIS 3.20 and I'm trying to install the Plugin DirectionalSlope.

However, when I click the install button this error appears:

ModuleNotFoundError: No module named 'gdal' 
Traceback (most recent call last):
  File "C:\PROGRA~1/QGIS32~1.3/apps/qgis/./python\qgis\utils.py", line 313, in loadPlugin
    __import__(packageName)
  File "C:\PROGRA~1/QGIS32~1.3/apps/qgis/./python\qgis\utils.py", line 799, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\Users/AWF/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\DirectionalSlope\__init__.py", line 3, in 
    from .DirectionalSlope import DirectionalSlope
  File "C:\PROGRA~1/QGIS32~1.3/apps/qgis/./python\qgis\utils.py", line 799, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\Users/AWF/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\DirectionalSlope\DirectionalSlope.py", line 38, in 
    from .DirectionalSlope_classes import *
  File "C:\PROGRA~1/QGIS32~1.3/apps/qgis/./python\qgis\utils.py", line 799, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\Users/AWF/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\DirectionalSlope\DirectionalSlope_classes.py", line 10, in 
    import gdal
  File "C:\PROGRA~1/QGIS32~1.3/apps/qgis/./python\qgis\utils.py", line 799, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'gdal'


Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] 
QGIS version: 3.20.3-Odense Odense, 495fbaec 

Python Path:
C:/PROGRA~1/QGIS32~1.3/apps/qgis/./python
C:/Users/AWF/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/AWF/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA~1/QGIS32~1.3/apps/qgis/./python/plugins
C:\Program Files\QGIS 3.20.3\bin\python39.zip
C:\PROGRA~1\QGIS32~1.3\apps\Python39\DLLs
C:\PROGRA~1\QGIS32~1.3\apps\Python39\lib
C:\Program Files\QGIS 3.20.3\bin
C:\PROGRA~1\QGIS32~1.3\apps\Python39
C:\PROGRA~1\QGIS32~1.3\apps\Python39\lib\site-packages
C:\PROGRA~1\QGIS32~1.3\apps\Python39\lib\site-packages\win32
C:\PROGRA~1\QGIS32~1.3\apps\Python39\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS32~1.3\apps\Python39\lib\site-packages\Pythonwin
C:/Users/AWF/AppData/Roaming/QGIS/QGIS3\profiles\default/python

What is the problem and what can I do to solve it? Keep in mind that I am new to the program and I don't use Python at all. I just want to use this plugin.

3
  • how did you install qgis? by the standalone installer or by OS4Geo? (sorry, posted this comment accidently as answer)
    – sn1ks
    Oct 12 '21 at 11:12
  • 1
    I edited my question. I use the standalone version.
    – Koumkou
    Oct 12 '21 at 11:14
  • ok - i edited my previously deleted answer. should do the trick!
    – sn1ks
    Oct 12 '21 at 11:16
3

I, sometimes, encounter that problem right after QGIS installation. Downloading the wheel file from Unofficial Windows Binaries for Python Extension Packages generally solves the problem.

In your case,

  • Download any ******-cp39‑win_amd64.whl (maybe the latest version).
  • Open OSGeo shell.
  • (You may need to uninstall previous GDAL. Use python -m pip uninstall gdal
  • Use python -m pip install "FULL_PATH_OF_GDAL_WHL_FILE" -U

If you still get any error about GDAL, try different version of GDAL on the website.

6
  • I downloaded the GDAL‑3.3.2‑cp39‑cp39‑win_amd64.whl. Do i place it in a particular folder in the OSGeo4W and then install it? Or do I Install it from any path?
    – Koumkou
    Oct 13 '21 at 10:53
  • Install it from any path like python -m pip install c:\users\user\downloads\GDAL‑3.3.2‑cp39‑cp39‑win_amd64.whl -U Oct 13 '21 at 11:37
  • I forgot -U parameter. U means upgrade. Oct 13 '21 at 11:38
  • It shows me this error ERROR: Cannot uninstall 'GDAL'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. Can I do something to solve it?
    – Koumkou
    Oct 13 '21 at 11:49
  • I have no idea at this point? Oct 13 '21 at 12:00
2

Use the network installer (recommended for normal users). this will ensure all the dependencies will be installed - gdal is one of those. To make sure of it use "advanced installation". In the step where you can actually choose the packets to install, search for "gdal" - this is how it looks at my machine: enter image description here

6
  • I uninstalled the standalone version, and i used the network installer but it didnt solved the problem. Is there anything else I can do?
    – Koumkou
    Oct 13 '21 at 6:41
  • edited the answer - have you verified that gdal is installed according to the network installer tool?
    – sn1ks
    Oct 13 '21 at 7:04
  • How to you do that? From the OSGeo4W shell? This shows me that i have the GDAL 3.3.1 Version but it still doesnt work.
    – Koumkou
    Oct 13 '21 at 7:40
  • I did the advanced setup like you said but still no result.
    – Koumkou
    Oct 13 '21 at 7:41
  • in QGIS, go to Settings->Options-> Processing->Providers-> GDAL is the box checked here?
    – sn1ks
    Oct 13 '21 at 7:56
1

You must report this issue to the plugin author.

This plugin is using an outdated way of importing gdal into his algorithms.

import gdal

is deprecated for many years.

The author must upgrade the plugin to

from osgeo import gdal

If you go edit C:\Users/AWF/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\DirectionalSlope\DirectionalSlope_classes.py line 10, you can do it yourself. But you may have other imports in another area of the code. And your update will be overwritten by a plugin update, so better to report it to plugin author.

2
  • You are right. I edited line 10 and then an error returned for line 11 because there is no module 'gdalconst'. So i may have to contact the editor. But the strange thing is that this plugin has worked perfectly for a coworker without doing anything. I dont know why.
    – Koumkou
    Oct 13 '21 at 13:28
  • Which QGIS version for your coworker ? Which OS ? The important thing is the version of GDAL provided by your QGIS. In the help/about menu, you will find it. I think it's GDAL/OGR 3.1. Can you say thisanswer solve your problem ?
    – etrimaille
    Oct 13 '21 at 14:26
0

Should be just the GDAL imports style. Fixed in https://gitlab.com/mauroalberti/directionalslope/-/tags/v1.3.2 and submitted new version to the QGIS plugin repository for approval.

1
  • Thanks to etrimaille and Koumkou for pointing to the issue.
    – MauroA
    Oct 15 '21 at 20:16

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.