Hi all,
This might be something simple I’ve missed, but I’ve hit an issue in Rhino 8 using the Python 3 Grasshopper scripting environment.
I’ve been using this import for a while without issue:
from Grasshopper import DataTree
Earlier today, this worked fine across multiple Python 3 components in my script. After restarting Rhino, the exact same scripts now throw:
ImportError: cannot import name ‘DataTree’ from ‘Grasshopper’ (unknown location)
I am quite new to this all so forgive me if I’ve missed something obvious.
I’ve tried:
Restarting
Using in IronPython & legacy python (works in both of those)
Clearing .rhinocode cache
Any guidance appreciated.
Thanks
Japhy
(Japhy)
April 21, 2025, 8:13pm
2
There was a similar one recently, but at the moment only finding this older response..
Only just that one can also always use the sys.path.append method to explicitly add paths within a Python script itself (i.e. prior to importing). That might help with your importing goals:
import sys
# Point to a folder with Python modules in it
myPath = r"C:\Users\ander\OneDrive\Desktop"
# Add to the folder importable paths if it's not already in there
if myPath not in sys.path:
sys.path.append(myPath)
# Check folders you can import from
for p in sys.path:
print p
eirannejad
(Ehsan Iran-Nejad)
April 26, 2025, 9:26am
3
@James_Owen Do you have Grasshopper 2 installed by any chance? If yes make sure to get the latest GH2 as it has a corrected Grasshopper2
top-level namespace and avoids conflict with Grasshopper
namespace
Looks like I’m on Grasshopper 1 - I’ll look into this, thank you.