State:New|TargetRelease:No Target|icon_bug|icon_nuke|database:public|Resolution:Fixed|BugID:146335|
Problem summary:
"A PythonObject is not attached to a node" error occurs when accessing the root node with callbacks while loading a file from the File menu
Customer reported version:
Nuke 13.2v8
Customer reported platform:
CentOS 7
Steps to reproduce:
1) Add the following code to the ~/.nuke/init.py or ~/.nuke/menu.py files:
def myFunc(): nuke.root().format()nuke.addOnCreate(myFunc)
2) Launch Nuke, then open any script with File > Open or File > Recent.
3) Observe the pop up message saying "A PythonObject is not attached to a node", and the error(s) printed to Nuke's Terminal:

Traceback (most recent call last): File "C:\Program Files/Nuke14.0v5/plugins\nuke_internal\callbacks.py", line 72, in onCreate _doCallbacks(onCreates) File "C:\Program Files/Nuke14.0v5/plugins\nuke_internal\callbacks.py", line 51, in _doCallbacks f[0](*f[1],**f[2]) File "C:/Users/<username>/.nuke/init.py", line 2, in myFunc nuke.root().format()ValueError: A PythonObject is not attached to a nodeTraceback (most recent call last): File "<string>", line 1, in <module>RuntimeError: A PythonObject is not attached to a node
Expected behavior:
Callbacks that utilize the root node should not create errors when a file is opened from the File menu.
Actual behavior:
If the knobs on the root node are queried by an onCreate or knobChanged callback, then opening a script from the File menu (File > Open or File > Recent) will result in a "PythonObject is not attached to a node" error message.
Workaround:
Use try and except code blocks when you attempt to access the root node, like so:
def myFunc(): try: nuke.root().format() except: passnuke.addOnCreate(myFunc)
Additionally, launching Nuke to open a script directly will prevent the error message from occurring initially:
"C:\Program Files\Nuke14.0v5\Nuke14.0.exe" "C:\path\to\the\file.nk"
However, when the file is closed you will likely encounter the error again, as described in the bug report here: ID 516268 - Nuke displays "ValueError: A PythonObject is not attached to a node" in the terminal on shutdown when using nuke.root().name()
Reproduced by Support in:
Nuke 14.0v5 - Windows 10, CentOS 7
Nuke 14.0v1 - Windows 10
Nuke 13.0v1 - Windows 10
Nuke 12.0v1 - Windows 10
Nuke 11.0v1 - Windows 10
Nuke 10.0v1 - Windows 10, CentOS 7
Earliest version tested:
Nuke 10.0v1 - This issue appears to be in all tested versions of the product
We're sorry to hear that
Please tell us why