UMEP-dev / UMEP

Urban Multi-scale Environmental Predictor
https://umep-docs.readthedocs.io/
59 stars 15 forks source link

URock Simulation Index Error #614

Closed husamah7 closed 2 months ago

husamah7 commented 2 months ago

Hello, I'm running URock simulation on QGIS (QGIS version: 3.36.1-Maidenhead). After generating "building_urock.shp" and "veg_urock.shp" using the pre-processor and saving them in a separate folder. when running the URock simulation, I get this error. I cannot figure out why I keep getting this error or what I need to do to fix it, especially since I do not have so much expertise in coding.

Traceback (most recent call last): File "/Users/husamalahmadieh/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/processing_umep/processor/urock_processing_algorithm.py", line 324, in processAlgorithm javaDirDefault = getJavaDir(plugin_directory) File "/Users/husamalahmadieh/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/processing_umep/functions/URock/H2gisConnection.py", line 234, in getJavaDir javaPath = getJavaHome(os_type) File "/Users/husamalahmadieh/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/processing_umep/functions/URock/H2gisConnection.py", line 343, in getJavaHome javaPath = os.path.abspath(str(output).split("java.home = ")[1].split("\n")[0]) IndexError: list index out of range

Execution failed after 0.16 seconds

Loading resulting layers Algorithm 'Urban Wind Field: URock v2023a' finished

j3r3m1 commented 2 months ago

No worries it is not your expertise to debug that. Can you please open a QGIS Python Console and type the following (line by line) and then share what output message you get ?


import winreg
java_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\JavaSoft\Java Development Kit")
current_version, _ = winreg.QueryValueEx(java_key, "CurrentVersion")
java_version_key = winreg.OpenKey(java_key, current_version)
javaPath, _ = winreg.QueryValueEx(java_version_key, "JavaHome")
print(javaPath) 
husamah7 commented 2 months ago

Hello, thank you for your quick reply!!

here's the result: "# Python Console

Use iface to access QGIS API interface or type '?' for more info

Security warning: typing commands from an untrusted source can harm your computer

import winreg java_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\JavaSoft\Java Development Kit") currentversion, = winreg.QueryValueEx(java_key, "CurrentVersion") java_version_key = winreg.OpenKey(java_key, currentversion) javaPath, = winreg.QueryValueEx(java_version_key, "JavaHome") print(javaPath)\ Traceback (most recent call last): File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/code.py", line 63, in runsource code = self.compile(source, filename, symbol) File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/codeop.py", line 178, in call return _maybe_compile(self.compiler, source, filename, symbol) File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/codeop.py", line 106, in _maybe_compile raise err1 File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/codeop.py", line 93, in _maybe_compile code1 = compiler(source + "\n", filename, symbol) File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/codeop.py", line 143, in call codeob = compile(source, filename, symbol, self.flags, True) File "", line 1 import winreg ^ SyntaxError: multiple statements found while compiling a single statement"

j3r3m1 commented 2 months ago

You should copy and paste the first line to the python console and type enter, then the second, etc. Only at the end you will get a message

husamah7 commented 2 months ago

Oh i'm sorry, i missed that comment. I tried doing that, but the first line I get an error which I looked up and turns out it winreg is for windows. I am using a macOS system. What should I do differently?

Thank you so much for your help!!

j3r3m1 commented 2 months ago

I am using a macOS system.

Well, I did not realize that ! A first question I may have asked is do you have Java installed on your computer (cf. https://umep-docs.readthedocs.io/en/latest/Getting_Started.html#installing-the-umep-plugin) ?

husamah7 commented 2 months ago

I'm sorry, I should've specified what system I was using. I installed Java and now the URock simulation works. Thank you so much for your help!!

j3r3m1 commented 2 months ago

Nice to hear that. Enjoy !