QGIS-Plugin-Produce-Training-Samples-For-Deep-Learning icon indicating copy to clipboard operation
QGIS-Plugin-Produce-Training-Samples-For-Deep-Learning copied to clipboard

ModuleNotFoundError: No module named 'gdal'

Open hongzixiang opened this issue 3 years ago • 4 comments

I add the plugin using the zip from https://plugins.qgis.org/plugins/produce_training_data_for_deep_learning/. It can be installed but couldn't be load. The python error is bellow. 2022-02-24T21:22:43 CRITICAL Traceback (most recent call last): File "E:\QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 334, in startPlugin plugins[packageName] = package.classFactory(iface) File "C:\Users/97218/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\produce_training_data_for_deep_learning_init.py", line 35, in classFactory from .produce_training_data_for_deep_learning import produceTrainingDataForDeepLearning File "E:\QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 793, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\Users/97218/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\produce_training_data_for_deep_learning\produce_training_data_for_deep_learning.py", line 28, in import os, time, gdal File "E:\QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 793, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named 'gdal'

the QGIS version is 3.16.16-Hannover. I tried to uninstalled this plugin. But it can't work. I just study the cnn&rs and ues QGIS. I'm looking forward to your reply. thank you

hongzixiang avatar Feb 24 '22 13:02 hongzixiang

Hi @hongzixiang, could you please open the following file in notepad or any text editor and make following changes? Edit this file: C:\Users/97218/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\produce_training_data_for_deep_learning\produce_training_data_for_deep_learning.py

Current line number 1: import os, time, gdal

Change that to two different lines: import os, time from osgeo import gdal

Let me know how it goes.

PratyushTripathy avatar Feb 24 '22 14:02 PratyushTripathy

Thanks for your reply. I changed the line.. and the waring became: 2022-02-25T10:04:34 WARNING warning:C:\Users/97218/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\produce_training_data_for_deep_learning\dataGeneratorDeepLearning8.py:296: DeprecationWarning: invalid escape sequence \Q """

         traceback: File "", line 1, in 
          File "E:\QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 354, in startPlugin
          if not _startPlugin(packageName):
          File "E:\QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 334, in _startPlugin
          plugins[packageName] = package.classFactory(iface)
          File "C:\Users/97218/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\produce_training_data_for_deep_learning\__init__.py", line 35, in classFactory
          from .produce_training_data_for_deep_learning import produceTrainingDataForDeepLearning
          File "E:\QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 793, in _import
          mod = _builtin_import(name, globals, locals, fromlist, level)
          File "", line 1007, in _find_and_load
          File "", line 986, in _find_and_load_unlocked
          File "", line 680, in _load_unlocked
          File "", line 855, in exec_module
          File "", line 228, in _call_with_frames_removed
          File "C:\Users/97218/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\produce_training_data_for_deep_learning\produce_training_data_for_deep_learning.py", line 30, in 
          from .dataGeneratorDeepLearning8 import dataGeneratorClass
          File "E:\QGIS/apps/qgis-ltr/./python\qgis\utils.py", line 793, in _import
          mod = _builtin_import(name, globals, locals, fromlist, level)
          File "", line 1007, in _find_and_load
          File "", line 986, in _find_and_load_unlocked
          File "", line 680, in _load_unlocked
          File "", line 851, in exec_module
          File "", line 988, in get_code
          File "", line 918, in source_to_code
          File "", line 228, in _call_with_frames_removed

hongzixiang avatar Feb 25 '22 02:02 hongzixiang

Thanks for posting the solution above @PratyushTripathy It worked for me. I just needed to change this line in several other .py files as well

hal98x avatar May 22 '22 18:05 hal98x

I add the plugin using the zip from https://plugins.qgis.org/plugins/produce_training_data_for_deep_learning/. It can be installed but couldn't be load. The python error is bellow. Made the changes suggested by @PratyushTripathy but it did not work . any suggestions?

ModuleNotFoundError: No module named 'gdal Traceback (most recent call last): File "C:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 335, in startPlugin plugins[packageName] = package.classFactory(iface) File "C:\Users/xxxx/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\produce_training_data_for_deep_learning_init.py", line 35, in classFactory from .produce_training_data_for_deep_learning import produceTrainingDataForDeepLearning File "C:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 799, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\Users/xxxx/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\produce_training_data_for_deep_learning\produce_training_data_for_deep_learning.py", line 31, in from .dataGeneratorDeepLearning8 import dataGeneratorClass File "C:\OSGeo4W/apps/qgis/./python\qgis\utils.py", line 799, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\Users/xxx/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\produce_training_data_for_deep_learning\dataGeneratorDeepLearning8.py", line 1, in import os, gdal, math File "C:\OSGeo4W/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.2-Odense Odense, 9f59a156

rengifoo avatar Aug 04 '22 11:08 rengifoo