Configuring Pydev for Rhino.Python
NOTE: This article is specific to getting Pydev to work on Windows. I’ve had problems getting the ironpython interpreter to work inside Pydev on Mac. Hopefully this will inspire someone to hack away at the Mac version of Pydev and figure out what it takes to make it work for Rhino.Python.
What’s Pydev?
The folks at Pydev can probably do a much better job of explaining their product (http://pydev.org/index.html). In short, Pydev is a popular Python script editor (and debugger). Several python scripters who are familiar with Pydev have asked about how to configure it for editing Rhino.Python scripts.
Rhino for windows already comes with a built-in python editor, but I can understand that people will want to use a different editor for many reasons (they’re familiar with it or it has features that are missing in the Rhino editor.) Here’s the steps I took to get this to work on my Windows 7 computer.
A. Install Pydev – Here’s a page I used to get everything set up for Pydev http://pydev.org/manual_101_root.html
If you’ve already installed Pydev on your computer, you can skip this section.
- Download eclipse (http://www.eclipse.org/downloads/).
I downloaded Eclipse Classic 3.6.1 (~170MB) 32bit version for windows.
I downloaded the 32 bit version because I haven’t installed the 64 bit version of java on my computer and eclipse requires java to run.
File name is eclipse-SDK-3.6.1-win32.zip - Unzip file and double click on the eclipse.exe to start eclipse
- go to help->Install Software and type the following URL into the Work with text box
http://pydev.org/updates - You should get checkboxes for available pydev plug-ins. Check the Pydev item and click next, then finish
- This installs the pydev plug-in for eclipse
B. Install IronPython Executables
Rhino.Python uses Microsoft’s IronPython engine to process python scripts. Pydev is going to need to use this same engine in order to get things like auto-complete to work.
- Go to codeplex and Install “IronPython 2.6.2 for .NET 4.0” http://ironpython.codeplex.com/releases/view/41236
The download link is in the upper right corner of the web page - This installs the command IronPython command line interpreter which is needed by PyDev
C. Configure Pydev
- Start eclipse.exe
- Select Preferences from the Window menu
- Expand the Pydev node in the preferences tree and select “Interpreter – Iron Python”
- Click the “New…” button which brings up a “Select Interpreter” dialog
- Click the “Browse…” button and select ipy.exe which on my computer happens to be located at
C:\Program Files (x86)\IronPython 2.6\ipy.exe - Click OK and then another OK to accept the default folders added to the SYSTEM pythonpath
- Add the lib folder that contains the rhinoscript package to the system python path in order for Pydev to recognize any of the rhinoscript functions
- Add RhinoCommon as a “Forced Builtin”. In order to do this we need to create a directory that will be on the python path. I created a new folder in the eclipse directory called pydevrhino and added it to the python path by clicking the “New Folder” button on the Libraries tab and selecting this new folder. On my computer, this folder is located at
C:\Users\a-steve\Desktop\eclipse-SDK-3.5.2-win32\pydevrhino - Pydev has a limitation where it can only read .NET assemblies with a root namespace the same as the dll. We want to get at all of the classes inside of RhinoCommon.DLL, but the root namespace in this DLL is Rhino. Go to the Rhino5 system folder (where the main executable is located) and copy RhinoCommon.dll (and RhinoCommon.xml) to the new folder that you created in the previous step. In the new folder, rename these files to Rhino.dll and Rhino.xml (DON’T CHANGE THE FILES IN THE RHINO SYSTEM DIRECTORY).
- Go to the “Forced Builtins” tab, click New… button and type in “Rhino”.
On the Libraries tab click click the “New Folder” button and pick the directory where the rhinoscript package is located. You can find this folder location by looking at the Paths in the built-in Rhino.Python editor. On my computer this directory is located at
C:\Users\a-steve\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib
D. Start Using Pydev
Good luck!
Hi Steve,
Thanks for posting this…I followed your set up but am getting this error:
AttributeError: ‘LightException’ object has no attribute ‘Host’
Any ideas what could be causing it?
Thanks!
Sorry, I don’t. It’s been 4 years since this post and quite a bit may have changed in both the current Rhino and pydev since then.
Thanks a lot. All works like a charm. (Eclipse Luna)
Just installed in Win7 (w/ Mac BootCamp). Works perfectly !!!!.
Thanks.
Hi Steve,
Thank you for this post.
I just got a new machine (yay :)) and had to set up the workflow again. I had some troubles and I documented them, so I thought of sharing their solutions, it mabe useful for somebody.
Here is a link:
https://www.dropbox.com/s/g6jgpvbqy7564i2/PydevRhinoGrasshopper_SetUpGuide.pdf?dl=0
Cheers,
Miriam