I am using the Mac version of Rhino/Grasshopper. I am trying to import a module for using Python inside Grasshopper. When running the script, I receive the following error. I have AppKit
installed. I've even tried saving AppKit
and PyObjC
in a separate directory and using sys.path.append
to access it.
Any idea what I am doing wrong or can try?
Code:
import rhinoscriptsyntax as rs
import AppKit
Code:
import rhinoscriptsyntax as rs
my_path = '/Users/author/Desktop/pyobjc'
sys.path.append(my_path)
import AppKit
The IronPython implemented in Rhino 3D will have search paths that are separate from other Python environments you may have installed.
On Rhino for Windows, you would have been able to run EditPythonScript
in the Rhino command line to configure these paths via a dialog. Or _EditPythonScript
for a strictly command line approach.
But on Rhino for Mac configuring these paths is less straightforward. There is not yet an editor, debugger, or user interface for configuration fully baked in.
There is a work around using the Atom editor that works with Rhino 5.2 WIP 5C41w and later. After installing the rhino-python package for Atom :
control
+ option
+ s
to open the Rhino Python Search Paths panel. From your Python scripts in Rhino, you should now be able to import AppKit
and other packages from the newly specified locations.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.