简体   繁体   中英

Using Python in Grasshopper3D – Solution exception: No module named AppKit

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 :

  1. Press the control + option + s to open the Rhino Python Search Paths panel.
  2. Add or edit one or more paths. You cannot edit the default system paths, but can add custom search paths and edit these as needed.
  3. Click Save to update

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM