Nuke import PyOpenColorIO error


#1

Hi, developers,

I am importing nuke module (going fine) in my python script and get an error when open Nuke script:

sys.path.append('C:/Program Files/Nuke9.0v9/lib/site-packages')
import nuke
nuke.scriptOpen('C:/myFile.nk')

Error (see the same issue here):
ImportError: DLL load failed: The specified module could not be found.

I tried to add a path to this plugin but it did not help. Any thoughts?


#2

Are you trying to do this from a standard python installation? Or is this from within nuke?


#3

Standalone Python, not in Nuke! If I run this code in Nuke it does not bring an error.

It does not actually break the code execution (I open the Nuke script and do what I need to do with my nodes) but its quite annoying.


#4

I’ve never used Nuke, but I’m guessing that much like the python environment found in other DCC applications that they are using a non-standard C-runtime.

So if you want to use modules compiled for nuke with a standalone version of python you’d need to find out what compiler they built it with, and compile your own version of python to match.

Or if nuke is decent about things, they might ship their own version of the python interpreter which could be used for standalone scripts like this. Maya does this with mayapy.exe and houdini does this with hython.exe, 3DS Max does it as well, but I don’t remember what that one is called.

But on the whole, what you are currently trying to do is not possible.


#5

Its working, I just wish to get rid of missing module error…


#6

You can try doing a:

sys.path.append('C:/Program Files/Nuke9.0v9/lib/site-packages')
try:
   import nuke
   nuke.scriptOpen('C:/myFile.nk')
except ImportError as e:
   pass

That should swallow the error, but if its throwing such an error, it probably means that some module isn’t being loaded properly and you can’t guarantee that the script will work the same.