Cannot add script components to canvas

Hello,

I am unable to add any script components to the canvas.

Originally I got the following error window:

I updated the permissions to allow writing in that Rhino 8 folder.

Now when adding a python3 or IronPython component to the canvas it creates the component but it has the warning 1. No script to execute. Choose a language from component menu. and I cannot open the script interface. Doubleclicking does nothing.

went to the log file,a nd the most recent log has:

Info 10/14/2024 10:09:03 [RhinoCode] Language Registered: Plain Text 1.0 (rhinocode.builtin.text)
Info 10/14/2024 10:09:03 [RhinoCode] Language Registered: JSON 1.0 (rhinocode.builtin.json)
Info 10/14/2024 10:09:03 [RhinoCode] Language Registered: Git DotFile 1.0 (rhinocode.builtin.gitDotFile)
Info 10/14/2024 10:09:03 [RhinoCode] Language Registered: Yaml 1.0 (rhinocode.builtin.yaml)

the C# script component has the error message:
1. Failed to create code from "C#"

This is a clean install of Rhino 8 SR12 (8.12.24282.7001, 2024-10-08). Windows 11, GH1.0.0008

Any help would be great, Thanks!!

After dropping the component on the canvas and failing, run RhinoCodeLogs command in Rhino and share the logs. The window has a save menu item.

Thanks for reporting this

1 Like

Hey thanks for the reply.

when adding a new python3 component to the canvas I get this error:

Here’s the log file:
ScriptEditor.log (32.2 KB)

I hope that helps get things worked out. Thanks again!

Okay I see this error:

Error 10/15/2024 09:12:22 [RhinoCode] Error Initializing Python | Error deploying package "psutil-5.9.1-cp39-cp39-win_amd64.whl" | Python path configuration:  PYTHONHOME = '\\?\~/.rhinocode/py39-rh8/py39-rh8'  PYTHONPATH = (not set)  program name = '~/.rhinocode/py39-rh8/py39-rh8\python.exe'  isolated = 0  environment = 1  user site = 0  import site = 1  sys._base_executable = 'C:\\Program Files\\Rhino 8\\System\\~\\.rhinocode\\py39-rh8\\py39-rh8\\python.exe'  sys.base_prefix = '\\\\?\\~/.rhinocode/py39-rh8/py39-rh8'  sys.base_exec_prefix = '\\\\?\\~/.rhinocode/py39-rh8/py39-rh8'  sys.platlibdir = 'lib'  sys.executable = 'C:\\Program Files\\Rhino 8\\System\\~\\.rhinocode\\py39-rh8\\py39-rh8\\python.exe'  sys.prefix = '\\\\?\\~/.rhinocode/py39-rh8/py39-rh8'  sys.exec_prefix = '\\\\?\\~/.rhinocode/py39-rh8/py39-rh8'  sys.path = [    'C:\\Program Files\\Rhino 8\\System\\~\\.rhinocode\\py39-rh8\\py39-rh8\\python39.zip',    '\\\\?\\~/.rhinocode/py39-rh8/py39-rh8\\DLLs',    '\\\\?\\~/.rhinocode/py39-rh8/py39-rh8\\lib',    'C:\\Program Files\\Rhino 8\\System\\~\\.rhinocode\\py39-rh8\\py39-rh8',  ]Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encodingPython runtime state: core initializedModuleNotFoundError: No module named 'encodings'Current thread 0x0000a5c0 (most recent call first):<no Python frame>
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonRuntime.DeployPackages(CPythonStartupSteps startup)
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonRuntime.<>c__DisplayClass110_0.<InitRuntime>b__0(Access access)
   at Rhino.Runtime.Code.Languages.Runtime.Access.Run(String id, Action`1 task)
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonRuntime.InitRuntime(CPythonStartupSteps startup)
   at Rhino.Runtime.Code.Languages.PythonNet.CPython`1.Start()

For an odd reason script editor is failing at installing psutil package:

  • Try resetting python runtime from the main script editor:
  • Disconnect internet
  • Start Rhino and run ScriptEditor: Python will be set up from embedded packages and not from internet.

Unfortunately, I cannot even open the script editor. The first time I try to open it, it hangs for a while trying to load Python3, and then after that it fails immediately.

is there a way to reset the Python3 runtime outside of the Script Editor? anything else I can try? I do use conda environments for development, could it have something to do with that?

here is the log file in case that helps.

ScriptEditor161024.log (24.7 KB)

@OBucklin From what I can understand from the errors in the log file, it seems like scripting tools can not create temporary files and they fail. Would you mind:

  • Try to open ScriptEditor and let it fail
  • Open TestStaging.gh (2.6 KB) in Grasshopper and see if it outputs a file path or errors.
  • Close rhino, delete the %USERPROFILE%\.rhinocode\editor.json file and try opening the editor again

Hi Ehsan,

The script you sent me returns the path ~/.rhinocode/py39-rh8/stage\22kmmkae.yvf

unfortunately nothing seems to have changed after deleting the editor.json file.

@eirannejad hey thanks for the help up to this point. Do you have any other ideas how I can get scripting working?

When I reinstalled Rhino8, all my settings and aliases were still there. Could it be that the problem is somehow saved in some user configs? Do you know what I files I would need to delete to actually get a clean install? Thanks!

Hi @eirannejad

looking at the error, there’s this weird path that doesn’t seem like a valid one… or is it?

sys._base_executable = 'C:\\Program Files\\Rhino 8\\System\\~\\.rhinocode\\py39-rh8\\py39-rh8\\python.exe'

It appears in the sys.path as well.

Could it be environment variable related issue? wrong one set or with a wrong value or home dir variable incorrectly expanded?

Looking at the same log on my machine (works file)

Info 10/25/2024 13:33:09 [RhinoCode] PYTHONHOME: \\?\C:\Users\ckasirer\.rhinocode\py39-rh8

vs. this on Oliver’s machine:

Info 10/15/2024 09:12:21 [RhinoCode] PYTHONHOME: \\?\~/.rhinocode/py39-rh8/py39-rh8

Env var issue could also persist re-installs…

1 Like

Hi Ehsan,

Sorry to pester you, but this is very frustrating, as I consider scripting to be a crucial capability of Rhino, and it is currently completely nonfunctional. I tried to delete the user data files and then reinstall, but it did not help. Please let me know if you have any ideas.

Thanks

@OBucklin

I am sorry for being late on this. I was travelling and doing workshops.

Which Rhino version are you using that retuned a relative path like this? Would you mind sending me a screenshot of the test GH definition I sent above?

I am gonna DM you an internal Rhino 8.13/8.14 build and I would appreciate if you can test those. I have made some mods to isolate the python runtime from other pythons that might be on the machine so that might help as well.

1 Like

Hi again!

Rhino Version is Version 8 SR12
(8.12.24282.7001, 2024-10-08)

Here’s the screenshot of the GH script:

I will try the new build and let you know if anything changes.

Thanks!

ok the 8.13 build had the same behavior and I got the following popup:

unfortunately the 8.14 build had the same behavior.

just out of curiosity, I tried the C# script and got the following:

Could there be a mixup between file locations?
doesn’t the ~ refer to the user directory?

There is a .rhinocode folder in the C:\Program Files\Rhino 8\System\~\ folder and in the C:\Users\obucklin\ folder. Rhino seems to be looking at the one in Program Files but the RhinoCodeLogs are in C:\Users\obucklin\.rhinocode\logs. Those logs are empty, though.

Okay so seems like something is making Rhino create a wrong path `C:\Program Files\Rhino 8\System~.rhinocode\py3

Would you mind checking your Rhino options for this and see if there is a value set there? run ScriptEditor command and then check this in Rhino options:

Also run this and share screenshot

TestRoot.gh (3.9 KB)

1 Like

As I mentioned earlier, the ScriptEditor fails to open, so I can’t check it there, but in document properties I get

The GH script gives me:

Ok I deleted the RhinoCodePlugin.RootPath value, and now it works!!!

Looks like that was probably the problem all along. I don’t know how that got changed in the first place, but I’m just glad I can get back to work!

Thank you so much for your diligence helping me solve this issue!

1 Like

Of course! I am glad you got it resolved. Now I know what the problem could be in similar scenarios.