Using Eclipse with Nuke

Written by Sebastian Elsner on .

This tutorial will outline the steps to be taken to make Eclipse your Nuke IDE. Though the Nuke script editor has been improved recently, it's still worth looking for alternatives. Eclipse adds lots of extra features like auto completion, syntax checking or source exploration to make daily tasks easier to accomplish. Right now there is only one disadvantage: You would always have to copy/paste the code from eclipse to the Nuke script editor or constantly restart nuke to reload your python module (to help with that use Andreas Frickingers Call Updated Function script).

These are the steps to quickly setup Eclipse to be used with Nuke. If you need a more extensive and complete guide see the official Eclipse documentation: http://pydev.org/manual_101_root.html

 

1) Setting up Python

Get and install python for your platform (www.python.org)


2) Setting up Eclipse

Go to http://www.eclipse.org and download the Eclipse Classic package. Extract the package and when started go to the update manager (Help > Install New Software), click add and provide http://pydev.org/updates as a site location. Tick the PyDev item and follow the Eclipse steps to install the software.

After installing Eclipse, you have to configure your Python interpreter: window > preferences > pydev > Interpreter – Python. Select the interpreter you just installed (find the python.exe). You will never use this interpreter for nuke, because Nuke uses it own, but Eclipse requires you to specify one.

If you don't have the PYTHONPATH already set up for your environment, you can now add paths that will be in your SYSTEM PYTHONPATH. In the preferences window you can add a new folder to your Libraries section. In our case this would be the path where you keep all your nuke python modules.

 

3) Setting up code completion

Nuke's python definitions are not accessible from outside the Nuke script editor. Therefor we have to help ourselves with a dummy module. The dummy contains all definitions of nodes and functions Nuke is capable of, so Eclipse can parse the module and provide the completions.

Because the available nuke functions are of course subject to change this module would be very cumbersome to maintain. So we use a script to generate the nuke.py dummy module.

Get the nukePyDummy script, and open it in your favorite text editor. Edit the variable MODULE_DIR to point to a path you want the dummy module to be placed. Use a directory in your PYTHONPATH, preferably the path you just added in step 3. Start Nuke, copy and paste the contents of the script to your nuke script editor and execute it. If you did not get any error, navigate to the directory where the nuke.py was created and have a look at it – you should see class and function definitions. Restart Eclipse.

 

5) A first project

Now that all is configured, let's create our first test project. In the menu, go to: file > new > project > Pydev > Pydev project. Provide a name and the interpreter you want to use (in case you have more than one set up)

 

6) A first module

On the left side in the Package Explorer expand your project and right click the src folder. Select new > pydev module, fill in the module name and finish. Now type:

import nuke
nuke.
 

 

When typing nuke. the auto completion popup should show. If not press control + space to force it to come up. If it is still not working, check if your generated nuke.py is placed in the PYTHONPATH. If everything fails you can always just copy the nuke.py to your current projects working folder, so it will always be found.

 

TIPP: You do not have to use the nuke.py with Eclipse, in fact every editor who is capable of code completion can use the module. Eclipse is just the editor I like.

Comments   

 
0 # Robert Nederhorst 2010-08-08 11:07
I had multiple errors with this script.
First errors are when the nuke.py script gets created it generates syntax error on lines 1813 and 1824:
def __getattribute__(self,'name'):
I changed it to : def __getattribute__(self,name):

However, when I import the module I get this next error:
File "Z:softwarescripts
uke.py", line 1, in
class AColor_Knob(Color_Knob):
NameError: name 'Color_Knob' is not defined

Any help?

rob
 
 
0 # Sebastian Elsner 2010-08-08 19:43
hey,
I don't get any errors here on windows with Nuke 6.0v7. What are you using?

Concerning your errors: "lines 1813 and 1824" my script has only 160 lines?! You probably changed a file wich is part of your Python/Nuke distribution (usually a bad thing to do :-)) There must be somthing wrong different on your side.

Seems like you are actually USING the generated module. Its not meant to be used that way. Use it only for auto completion. The Classes and methods defined are only stubs, they do nothing! The particluar error you get is because the classes are defined in random order and some classes inherit from others so you get this error, that some base class is not defined. This is absolutely OK. because you do never import this module: Its not meant to make nuke functionality available outside of nuke.
 
 
0 # Robert Nederhorst 2010-08-09 08:52
I am using 6.1v1
Sorry the 1800 series lines are from the resulting nuke.py that your script generates.
The error happens when I do an import nuke in my external editor (Wing IDE).
I only want it for autocompletion as well so I am not processing with it, just trying to import it for that reason.
thanks!
 
 
0 # Sebastian Elsner 2010-08-09 09:21
Ok so this is Nuke 6.1 issue, because this is not generated with 6.0v7 (or eclipse is more permissive with these things). I will have a look at it next weekend. Perhaps I can also implement correct definition order.
 
 
0 # Robert Nederhorst 2010-08-09 09:28
Thanks for checking it out, sir. cheers.
 
 
0 # Eric Larsen 2011-03-24 17:15
Just tried this out with v6.2v2 and it works without issue. This is a great help!
 
 
0 # Dennis Serras 2011-05-01 21:49
Works fine for me too on 6.2v2. Thank you! Now if I can only figure out this nutty interface in Eclipse...
 
 
0 # Jason Taylor 2011-08-01 10:21
Worked great for me, thanks a ton!
 
 
0 # Carlos Trijueque 2011-09-03 09:31
Work fine here (6.3v2 PLE and Windows 7).

Very useful. Thanks a lot.
 
 
0 # wilson gaw 2012-12-18 20:04
Hi, I'm new to nuke currently using nuke 6.3V5, i have follow all the above instruction but somehow i cant get the auto completion working. there is one section that i don;t really understand, its the path where nuke python modules are kept. Sorry this may sound silly but where is it kept ?

Thanks
 
 
0 # Michael Loeffler 2014-03-24 14:27
Hi, another versy easy way to use the nuke library in python is to add its compiled python file from the site-packages folder.
 
 
0 # Michael Loeffler 2014-03-24 14:33
This is working for mie with Nuke 8.0v1.
Add the following path to your System PYTHONPATH in Eclipse:
NUKE_INSTALL_LOCATION\lib\site-packages

Thats it. I don't have to add anything else. also the autocompletion is working well.

Note:
In this location you should find "nuke.pyd" (windows compiled python file). This includes the whole class and module structure of all nuke python comands.
 
 
0 # Dennis Serras 2015-12-05 02:13
I was able to get the contents of nukescripts by changing the instances of the module "nuke" to "nukescripts" in nukePyDummy.
 

You have no rights to post comments

We have 2622 guests and 45 members online