Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: setMaximum(self, maximum: int): argument 1 has unexpected type 'float' #39

Open
IRTMonteiro opened this issue Jun 27, 2024 · 5 comments

Comments

@IRTMonteiro
Copy link

I'm trying to sort items in a stack of images, but when I run it the following error appears:
How do I resolve it?

`Um erro ocorreu enquanto executava o código Python:

TypeError: setMaximum(self, maximum: int): argument 1 has unexpected type 'float'
Traceback (most recent call last):
File "C:\Users/IRTM/AppData/Roaming/QGIS/QGIS3\profiles\IRTM/python/plugins\dzetsaka\dzetsaka.py", line 750, in runMagic
temp.initPredict(
File "C:\Users/IRTM/AppData/Roaming/QGIS/QGIS3\profiles\IRTM/python/plugins\dzetsaka\scripts\mainfunction.py", line 701, in initPredict
predictedImage = self.predict_image(
^^^^^^^^^^^^^^^^^^^
File "C:\Users/IRTM/AppData/Roaming/QGIS/QGIS3\profiles\IRTM/python/plugins\dzetsaka\scripts\mainfunction.py", line 850, in predict_image
progress = pB.progressBar('Predicting model...', total / 10)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users/IRTM/AppData/Roaming/QGIS/QGIS3\profiles\IRTM/python/plugins\dzetsaka\scripts\progressBar.py", line 38, in init
prgBar.setMaximum(inMaxStep)
TypeError: setMaximum(self, maximum: int): argument 1 has unexpected type 'float'

Versão do Python: 3.12.4 (main, Jun 10 2024, 12:48:35) [MSC v.1938 64 bit (AMD64)]
Versão do QGIS: 3.34.8-Prizren Prizren, 91642333

Caminho do Python:
C:\Users/IRTM/AppData/Roaming/QGIS/QGIS3\profiles\IRTM/python/plugins\OpenTopography-DEM-Downloader
C:/PROGRA1/QGIS331.8/apps/qgis-ltr/./python
C:/Users/IRTM/AppData/Roaming/QGIS/QGIS3\profiles\IRTM/python
C:/Users/IRTM/AppData/Roaming/QGIS/QGIS3\profiles\IRTM/python/plugins
C:/PROGRA1/QGIS331.8/apps/qgis-ltr/./python/plugins
C:\PROGRA1\QGIS331.8\apps\grass\grass83\etc\python
C:\Users\IRTM\Documents
C:\Program Files\QGIS 3.34.8\bin\python312.zip
C:\PROGRA1\QGIS331.8\apps\Python312\DLLs
C:\PROGRA1\QGIS331.8\apps\Python312\Lib
C:\Program Files\QGIS 3.34.8\bin
C:\PROGRA1\QGIS331.8\apps\Python312
C:\PROGRA1\QGIS331.8\apps\Python312\Lib\site-packages
C:\PROGRA1\QGIS331.8\apps\Python312\Lib\site-packages\win32
C:\PROGRA1\QGIS331.8\apps\Python312\Lib\site-packages\win32\lib
C:\PROGRA1\QGIS331.8\apps\Python312\Lib\site-packages\Pythonwin
C:/Users/IRTM/AppData/Roaming/QGIS/QGIS3\profiles\IRTM/python
C:\Users\IRTM\AppData\Roaming\QGIS\QGIS3\profiles\IRTM\python\plugins\kmltools\libs
D:/CursoGEOPRO/projetos
'

@Lahers
Copy link

Lahers commented Jul 25, 2024

Hello, to correct this error, you have to open the following file "progressBar.py", normally present in the plugin installation file, to then modify this line "prgBar.setMaximum(inMaxStep)", with this one "prgBar.setMaximum(int(inMaxStep))".
After this modification, the plugin worked correctly and displayed the automatic classification !

If you want, I explained the problem more specifically in a pull request but in the "closed" part right next to the "open" part.
Tell me if it works, for my part it worked and the plugin works perfectly now !

@dzcreators
Copy link

I experienced the same thing as that. I've tried the method above, but it doesn't work. Is there a solution?

image

TypeError: setMaximum(self, maximum: int): argument 1 has unexpected type 'float'
Traceback (most recent call last):
File "C:\Users/Mr. Maryono/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\dzetsaka\dzetsaka.py", line 750, in runMagic
temp.initPredict(
File "C:\Users/Mr. Maryono/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\dzetsaka\scripts\mainfunction.py", line 701, in initPredict
predictedImage = self.predict_image(
^^^^^^^^^^^^^^^^^^^
File "C:\Users/Mr. Maryono/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\dzetsaka\scripts\mainfunction.py", line 850, in predict_image
progress = pB.progressBar('Predicting model...', total / 10)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users/Mr. Maryono/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\dzetsaka\scripts\progressBar.py", line 38, in init
prgBar.setMaximum(inMaxStep)
TypeError: setMaximum(self, maximum: int): argument 1 has unexpected type 'float'

Python version: 3.12.4 (main, Jun 10 2024, 12:48:35) [MSC v.1938 64 bit (AMD64)]
QGIS version: 3.34.9-Prizren Prizren, cbbc7bdf

Python Path:
C:/PROGRA1/QGIS331.9/apps/qgis-ltr/./python
C:/Users/Mr. Maryono/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/Mr. Maryono/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA1/QGIS331.9/apps/qgis-ltr/./python/plugins
C:\PROGRA1\QGIS331.9\apps\grass\grass83\etc\python
C:\Users\Mr. Maryono\Documents
C:\Program Files\QGIS 3.34.9\bin\python312.zip
C:\PROGRA1\QGIS331.9\apps\Python312\DLLs
C:\PROGRA1\QGIS331.9\apps\Python312\Lib
C:\Program Files\QGIS 3.34.9\bin
C:\Users\Mr. Maryono\AppData\Roaming\Python\Python312\site-packages
C:\PROGRA1\QGIS331.9\apps\Python312
C:\PROGRA1\QGIS331.9\apps\Python312\Lib\site-packages
C:\PROGRA1\QGIS331.9\apps\Python312\Lib\site-packages\win32
C:\PROGRA1\QGIS331.9\apps\Python312\Lib\site-packages\win32\lib
C:\PROGRA1\QGIS331.9\apps\Python312\Lib\site-packages\Pythonwin
C:/Users/Mr. Maryono/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:\Users\Mr. Maryono\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\AcATaMa\extlibs
D:/C-GREINDE/9. Masterplan Pesisir/3. GIS/Raster/Analisis Mangrove

@Icarus35666
Copy link

Same issue for me too. I've tried with QGIS LTR and 3.38. I've change the progressBar.py file but the issue is worst and make qgis crashing directly. I'm using Windows 10 (64bit) and OSGeo4W to install qgis and python-scikit-learn package.

@manaka2797
Copy link

The same above too. Does anyone know how to fix it?

@Ihor657
Copy link

Ihor657 commented Nov 24, 2024

This solution helped me from the GPT chat.
Solution:
Ensuring an integer value in progressBar:
Make changes to the code in mainfunction.py, line 850. Wrap total / 10 with the int() function:

python
Копировать код
progress = pB.progressBar('Predicting model...', int(total / 10))
Analysis and correction in progressBar.py:
Check the init method in progressBar.py, specifically line 38:

python
Копировать код
prgBar.setMaximum(inMaxStep)
Add explicit conversion of inMaxStep to an integer:

python
Копировать код
prgBar.setMaximum(int(inMaxStep))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants