Rhinoscriptsyntax Module Search Paths overwrite

Good Morning together (=

for an internal scripting tool we use our own version of the rhinoscriptsyntax python module.
As Rhino 7 sets the module search paths on each start-up new to the standard rhinoscriptsyntax at the top of all search paths, it is cumbersome to manually remove the standard path each time.

Is there a way to either overwrite or to remove the behavior that it loads the defaults on each start-up?
As I got told by a colleague this behavior has not been the case in Rhino 5.

Thanks a lot for your help.
Kindest regards


I’ve never found a way to set the environment variable PYTHON_PATH in Rhino, much as I’d love to know of one. But you can still do in Rhino, what you’re not supposed to do in regular Python, and add it to sys.path below.

Don’t manually remove it, or overwrite sys.path unless you want to block access to all the other iron python modules, in favour of your own. Insert your path before them instead, so your path is searched first:

import sys
if your_path not in sys.path:
    sys.path.insert(0, your_path)

This adds a little boiler plate to each script, but it’s a small price to be able to develop scripts (and test pure python scripts) outside of the Rhino IDE, and import them into Rhino.

If you control all your user’s machines, then for maintainability and DRY, you can set your_path as an environment variable, and read it using os.getenv.

1 Like

Hey @James_Parrott,
thanks for your answer. Although this is not what I am looking for.

What I would like is to use my own branch of the rhinoscriptsyntax, which works fine,
apart from that on each start-up the default rhinoscriptsyntax search path gets added again to
the module search path list.

Which leads to the situation, that I have to go in the Python Options and remove the standard path, each time.

But still thanks for your answer I appreciate (:

This is pretty sketchy, but sys.path.remove() might work. That said, why don’t you just name your custom rhinoscriptsyntax module something else?

You’re welcome. Sorry I can’t help further.
In GhPython, rhinoscriptsyntax need not be imported at all if you don’t need it.
Doesn’t RhinoPython also let you control the imports in your script, or is rhinoscriptsyntax always required, and available in the namespace automagically (like ghdoc)?

In Grasshopper Python, if you don’t include import rhinoscriptsyntax, you don’t get it. Or any other module you like can be imported, and assigned to the name rhinoscriptsyntax (or rs) with import X as Y.

Thanks for the reply @AndersDeleuran.
This might work but is not really an option on our side, as the use of our rhinoscriptsyntax fork should be optional with our libraries. =/

As mentioned before it seems to be a behavior only appearing from Rhino 6 upwards.

Hi @moritz.niebler it’s not sure this will get changed, but I’ve added:
RH-72855 EditPythonScript: delete default search paths
@AndersDeleuran 's suggestion would be best if possible.

Side note : I’ve tested by deleting the paths and restarting Rhino 5 and this left EditPythonScript dead until I removed the settings folder. It might be the reason this was changed.


Hey @Gijs thanks a lot for the answer.
That is good to see it gets tracked and also good to know this wont change,
so I can look for another reasonable solution.

Thank you (: