TransWikia.com

GDAL import error, broken both python script and Qgis

Geographic Information Systems Asked by justin larking on July 9, 2021

I have both a standalone script trying to use gdal and Qgis both of which have run into an error with importing gdal:

My script errors:

line 18, in <module>
    import gdal
  File "/usr/lib/python3/dist-packages/gdal.py", line 2, in <module>
    from osgeo.gdal import deprecation_warn
ModuleNotFoundError: No module named 'osgeo.gdal'

and if I try from osgeo import gdal:

line 18, in <module>
    from osgeo import gdal
ImportError: cannot import name 'gdal' from 'osgeo' (/home/justinlarking/.local/lib/python3.8/site-packages/osgeo/__init__.py)

This is also affecting my Qgis as in I cant open it:
enter image description here

Full Qgis error:

Couldn't load plugin 'shapetools' due to an error when calling its classFactory() method 

ImportError: cannot import name 'gdal' from 'osgeo' (/home/justinlarking/.local/lib/python3.8/site-packages/osgeo/__init__.py) 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 334, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/home/justinlarking/.local/share/QGIS/QGIS3/profiles/default/python/plugins/shapetools/__init__.py", line 10, in classFactory
    from .shapeTools import ShapeTools
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 792, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/justinlarking/.local/share/QGIS/QGIS3/profiles/default/python/plugins/shapetools/shapeTools.py", line 5, in 
    import processing
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 792, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/share/qgis/python/plugins/processing/__init__.py", line 35, in 
    from processing.tools.raster import *  # NOQA
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 792, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/share/qgis/python/plugins/processing/tools/raster.py", line 26, in 
    from osgeo import gdal
ImportError: cannot import name 'gdal' from 'osgeo' (/home/justinlarking/.local/lib/python3.8/site-packages/osgeo/__init__.py)


Python version: 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] 
QGIS version: 3.16.2-Hannover Hannover, f1660f9da5 

Python Path:
/usr/share/qgis/python
/home/justinlarking/.local/share/QGIS/QGIS3/profiles/default/python
/home/justinlarking/.local/share/QGIS/QGIS3/profiles/default/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python38.zip
/usr/lib/python3.8
/usr/lib/python3.8/lib-dynload
/home/justinlarking/.local/lib/python3.8/site-packages
/usr/local/lib/python3.8/dist-packages
/usr/lib/python3/dist-packages
/home/justinlarking/.local/share/QGIS/QGIS3/profiles/default/python
/home/justinlarking/.local/share/QGIS/QGIS3/profiles/default/python/plugins/shapetools/ext-libs

Can anyone help me understand why my GDAL has broken? I did remove it and reinstall it however it is the same version as it was previously.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP