Viktor-Grasshopper: JSONDecodeError

Hello

I have a problem when i run the run_grasshopper.py app, i get a “RequestsJSONDecodeError”. I was trying to test the example .gh - script which i downloaded from the tutorial. Maybe someone knows what could be the problem here…

Traceback (most recent call last):
File “D:\Programme\Viktor\viktor-grasshopper\venv\lib\site-packages\requests\models.py”, line 960, in json
return complexjson.loads(self.content.decode(encoding), **kwargs)
File “C:\Users\sahen\AppData\Local\Programs\Python\Python310\lib\json_init_.py”, line 346, in loads
return _default_decoder.decode(s)
File “C:\Users\sahen\AppData\Local\Programs\Python\Python310\lib\json\decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “C:\Users\sahen\AppData\Local\Programs\Python\Python310\lib\json\decoder.py”, line 355, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “D:\Programme\Viktor\viktor-grasshopper\run_grasshopper.py”, line 26, in
output = gh.EvaluateDefinition(
File “D:\Programme\Viktor\viktor-grasshopper\venv\lib\site-packages\compute_rhino3d\Grasshopper.py”, line 57, in EvaluateDefinition
response = Util.ComputeFetch(url, args)
File “D:\Programme\Viktor\viktor-grasshopper\venv\lib\site-packages\compute_rhino3d\Util.py”, line 35, in ComputeFetch
return r.json()
File “D:\Programme\Viktor\viktor-grasshopper\venv\lib\site-packages\requests\models.py”, line 968, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 2 column 1 (char 2)

Hi @Broesmeli ,

Welcome to the forum!

Thanks for putting this up; I found out there is a mistake in our tutorial.

Accidentally a Python component has slipped in, in our upload. If you remove this red component; it should work. We will try to fix the tutorial as soon as possible!

Rick

1 Like

Hey Rick

Thank you for your reply!

Python Version 3.10
Pycharm 2023.3.3 (Community Edition)
Rhino 8

Yes i did that already but still i get the same error message…
I think i tried everything. Maybe you can help me further investigate the problem?

Thanks a lot!
Samuel

Hi,

In that case, unfortunately there is probably something going wrong.

For now your script is trying to send over data to Rhino.Compute and trying to encode the result immediately to json. However if there is an error in Rhino.Compute; it cannot encode the result (which is what your error is saying).

To solve this issue; we need to know what happened in your Rhino.Compute. To know this; open your Rhino.Compute terminal and paste the error message. If you don’t see it active you can open it by:

In grasshopper go to File → Preferences → Solver → Hide Rhino.Compute at start

Then restart Rhino. Once Grasshopper starts; it should open a Rhino.Compute terminal where you should see the error message as well (with more detail). Feel free to post that.

We do realize that debugging through Rhino.Compute is quite difficult; so we are actively developing a better solution!

Rick

Hey Rick

Sorry i didn’t post the Rhino.Compute Log before, so here it is.
There’s an Application startup exception as soon as i run the “Run_Grasshopper.py” file.

[20:32:08 INF] Rhino compute started at 15.02.2024 20:32:08
[20:32:08 INF] Initiliazing reverse proxy at 15.02.2024 20:32:08
[20:32:08 INF] Spawn children at startup is set to True
[20:32:08 INF] Now listening on: http://localhost:6500
[20:32:08 INF] Application started. Press Ctrl+C to shut down.
[20:32:08 INF] Hosting environment: Production
[20:32:08 INF] Content root path: C:\Users\sahen\AppData\Roaming\McNeel\Rhinoceros\packages\8.0\Hops\0.16.4\rhino.compute
CG [20:32:13 INF] Child process started at 15.02.2024 20:32:13
CG [20:32:13 INF] Parsed port = 6001
CG [20:32:16 FTL] Application startup exception
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at Rhino.Runtime.InProcess.RhinoCore.InternalStartup(Int32 argc, String argv, StartupInfo& info, IntPtr hostWnd)
at Rhino.Runtime.InProcess.RhinoCore…ctor(String args, WindowStyle windowStyle, IntPtr hostWnd)
at Rhino.Runtime.InProcess.RhinoCore…ctor(String args, WindowStyle windowStyle)
at compute.geometry.Startup.RhinoCoreStartup() in D:\BuildAgent\work\4852f584398a78e4\src\compute.geometry\Startup.cs:line 45
at compute.geometry.Startup.Configure(IApplicationBuilder app) in D:\BuildAgent\work\4852f584398a78e4\src\compute.geometry\Startup.cs:line 30
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
CG [20:32:16 INF] Now listening on: http://localhost:6001
CG [20:32:16 INF] Application started. Press Ctrl+C to shut down.
CG [20:32:16 INF] Hosting environment: Production
CG [20:32:16 INF] Content root path: C:\Users\sahen\AppData\Roaming\McNeel\Rhinoceros\packages\8.0\Hops\0.16.4\rhino.compute
[20:32:25 ERR] HTTP POST /grasshopper responded 500 in 173.4399 ms

Update: I think i just got the solution. I am running a trial version of Rhino right now and someone in the Rhino Community pointed this out that this was the problem for them. I will get a licence and try it again :slight_smile: thanks for your help!

Thanks for posting the solution!

Have fun!

1 Like