Scott Bird
Scott Bird

Reputation: 1

Cannot get Nuke module to import

I have tried many different versions of the following.

Standard Imports

import sys

sys.path.append('C:\Program Files\Nuke9.0v6\pythonextensions\site-packages')

Nuke Imports

import nuke

print(nuke.NUKE_VERSION_STRING)

No matter how I try to link to the environment I am still not able to import the nuke module.

Traceback (most recent call last): File "C:\Users\meand\Desktop\LatestTRY\nuketest.py", line 8, in print(nuke.NUKE_VERSION_STRING) AttributeError: module 'nuke' has no attribute 'NUKE_VERSION_STRING'

I'm pretty new to programming and racked my brain a while trying to get this working. It seems like I just need to point python to a different directory than it thinks but I cant get it working.

I also used this method to change variable and it gives the same error.

import os

nuke_path = os.environ['NUKE_PATH']

import nuke

Ive tried every method I've found online for solving this problem, but wonder if the software has outdated the solutions online. Nothing seems to work. Would love any input on how to get nuke 9 working in python.

Upvotes: 0

Views: 715

Answers (1)

pitvfx
pitvfx

Reputation: 1

First, Nuke9 still used Python2 so you'd have to filter out Python3 answers when scraping the internet.

Second, the nuke module is imported correctly, otherwise, you'd get a ModuleNotFoundError, instead of an AttributeError.

So try this:

import nuke
print nuke.NUKE_VERSION_STRING

If this still throws the same error, it might be that NUKE_VERSION_STRING really wasn't available in Nuke9. It's been quite some time and I really can't remember. In this case, try this instead.

import nuke
nuke.createNode('Blur')

You should see a new Blur node in your Node Graph. If not, there's something really odd and you should show exactly how and where you run the code in nuke.

Hope this helped.

Upvotes: 0

Related Questions