Importing Python methods from my own library in Rhino and Grasshopper on macOS?

(P1r4t3b0y) #1


I have created a Python file, called, with handy functions that work in accordance with rhinoscriptsyntax. I want to be able to import my library in Rhino and Grasshopper Python, but I don’t know where I have to put the
To be clear I want to be able to import the methods of in other Rhino Python scripts and within the Grasshopper Python Component. I have the latest version of Rhino 5 for macOS!

Any Ideas?

Thank you.

(Lando Schumpich) #2

Put it in the same folder rhino stores it’s scripts in by default. When you type ‘_EditPythonScript’ rhino will show you the location. You can import any python file in the scripts folder into ghpython nodes and rhinopython scripts it’s as simple as writing

Import my

(P1r4t3b0y) #3

In Rhino for Mac, ‘_EditPythonScript’ is an unknown command. It doesn’t open the Script Editor like on Windows. All you can do to run Python script is, use the command ‘RunPythonScript’, which just opens a system dialogue, where you can select your Python file and upon confirmation, Rhino will run it in the background.

(qythium) #4

Run this in a GhPython component, it will tell you all the locations the import statement searches in.

import sys
print '/n'.join(sys.path)

(you can also append to the sys.path like any other list to tell it to look in a specific location)

The main scripts folder should be in ~/Library/Application Support/McNeel/Rhinoceros/scripts

(P1r4t3b0y) #5

Thanks, qythium. Worked like a charm!