Nuke as a Python Module

You can import Nuke as a module into a third-party Python 3.9.10 interpreter, granting full access to the Nuke Python-API, but from within a native Python interpreter instead of Nuke.

Note:  Importing Nuke as a Python module is unavailable on macOS. Instead, use the Python build that ships with Nuke, which can be found here:
/Applications/Nuke15.1v5/Nuke15.1v5.app/Contents/MacOS/python.app

On Windows, if you are trying to import the Nuke module into a third-party Python interpreter, you can add C:\Program Files\Nuke<version> to your PATH environment variable. See Environment Variables for more information.

Note:  Foundry cannot provide customer support for third-party Python interpreters.

To run Nuke as a Python module:

1.   Add the file path for Nuke's site-packages directory to the usrlocal.pth file in your Python 3.9.10 install.

For example, if you're running on Windows, add C:\Program Files\Nuke15.1v5\lib\site-packages to the usrlocal.pth file.

Tip:  You can also use relative paths to the directory containing the usrlocal.pth file.

2.   At the Python prompt, use the import nuke declaration to make Nuke’s Script Editor functions and commands (such as nuke.nodes.Blur() to add a Blur node) available in your chosen Python interpreter.

The import nuke function checks-out a nuke_r render license by default. If you want to use Nuke interactively, and you have a nuke_i license, set the NUKE_INTERACTIVE environment variable to 1.

See Environment Variables for more information on setting environment variables.

For more information, see Nuke as a Python Module in the Nuke developer documentation.