semiautomaticgit/SemiAutomaticClassificationPlugin

AttributeError: 'str' object has no attribute 'dataProvider'

stochastic-sleuth opened this issue · 6 comments

Hi,
I am having the following error preventing me from classifying imagery, using spectral angle mapping and a previously created .scp file, after several successful iterations previously in an older SCP version. I am running QGIS 3.16 and SCP 7.10.6 using python 3.9. Please let me know how I can help troubleshoot this error.

Thanks,
Jess

2022-06-17T15:26:18 WARNING Traceback (most recent call last):
File "/Users/jessefrey/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/SemiAutomaticClassificationPlugin/maininterface/classificationTab.py", line 121, in runClassificationAction
self.runClassification(bandSetNumber = bndStN, algorithmFilesCheck = algFilesCheck, reportCheck = report, vectorConversion = vector, useMacroclass = macroclass, useLcs = useLcs, useLcsAlgorithm = useLcsAlgorithm, LCSLeaveUnclassified = leaveUnclassified, maskCheckBox = maskC, maskPath = maskPath)
File "/Users/jessefrey/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/SemiAutomaticClassificationPlugin/maininterface/classificationTab.py", line 212, in runClassification
self.applyClassSymbology(c, cfg.macroclassCheck, cfg.qmlFl, sL)
File "/Users/jessefrey/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/SemiAutomaticClassificationPlugin/maininterface/classificationTab.py", line 282, in applyClassSymbology
cfg.utls.rasterSymbol(classificationRaster, signatureList, macroclassCheck)
File "/Users/jessefrey/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/SemiAutomaticClassificationPlugin/core/utils.py", line 657, in rasterSymbol
lR = cfg.qgisCoreSCP.QgsPalettedRasterRenderer(classLayer.dataProvider(), cLB, cL)
AttributeError: 'str' object has no attribute 'dataProvider'

SemiAutomatic_python_error.txt

Thanks for your response. I found your guide very helpful, but I am unsure how to clean up my paths and I think that may be what is getting me stuck. I have tried a fresh install of QGIS 3.22 and ESA SNAP on a newly wiped PC and I am still having issues. Could you please help me understand how I can try to set up clean paths needed for this? I look forward to using this tool extensively for research thanks again.

An error has occurred while executing Python code:AttributeError: 'str' object has no attribute 'dataProvider'Traceback (most recent call last):File "C:\Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\maininterface\classificationTab.py", line 121, in runClassificationActionself.runClassification(bandSetNumber = bndStN, algorithmFilesCheck = algFilesCheck, reportCheck = report, vectorConversion = vector, useMacroclass = macroclass, useLcs = useLcs, useLcsAlgorithm = useLcsAlgorithm, LCSLeaveUnclassified = leaveUnclassified, maskCheckBox = maskC, maskPath = maskPath)File "C:\Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\maininterface\classificationTab.py", line 212, in runClassificationself.applyClassSymbology(c, cfg.macroclassCheck, cfg.qmlFl, sL)File "C:\Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\maininterface\classificationTab.py", line 282, in applyClassSymbologycfg.utls.rasterSymbol(classificationRaster, signatureList, macroclassCheck)File "C:\Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\SemiAutomaticClassificationPlugin\core\utils.py", line 657, in rasterSymbollR = cfg.qgisCoreSCP.QgsPalettedRasterRenderer(classLayer.dataProvider(), cLB, cL)AttributeError: 'str' object has no attribute 'dataProvider'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.22.8-Białowieża Białowieża, 8d5e9761dfPython

Path:C:/PROGRA1/QGIS321.8/apps/qgisltr/./pythonC:/Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA1/QGIS321.8/apps/qgisltr/./python/plugins
C:\PROGRA1\QGIS321.8\bin\python39.zip
C:\PROGRA1\QGIS321.8\apps\Python39\DLLs
C:\PROGRA1\QGIS321.8\apps\Python39\lib
C:\PROGRA1\QGIS321.8\bin
C:\PROGRA1\QGIS321.8\apps\Python39
C:\PROGRA1\QGIS321.8\apps\Python39\lib\site-packages
C:\PROGRA1\QGIS321.8\apps\Python39\lib\site-packages\win32
C:\PROGRA1\QGIS321.8\apps\Python39\lib\site-packages\win32\lib
C:\PROGRA1\QGIS321.8\apps\Python39\lib\site-packages\Pythonwin
C:/Users/jessica.frey/AppData/Roaming/QGIS/QGIS3\profiles\default/python
D:/Channel_width_NAIP

error.txt

Hello @stochastic-sleuth ,
it seems that the gpt executable path (which could be C:/Program Files/snap/bin/gpt.exe depending on SNAP installation) is not defined in SCP settings.
Please read https://semiautomaticclassificationmanual.readthedocs.io/en/latest/processingSettingTab.html#external-programs

Your documentation is excellent.

Thank you, I'm glad that it was useful to you.

Back on my mac, however, I have in /Applications/snap/bin/gpt in my processing settings and am still getting the same error. Does it need to be configured for python? I am running 3.9 and I notice Snap is not compatible with that version.

Setting the gpt path should be sufficient. However, recent versions of QGIS in MacOS have some issues with the installation of SCP. You can try to test if other SCP functions work, otherwise you should try to install a previous version of QGIS such as 3.18