Hi there,
I’ve been trying to update this Python script at work and it goes through Deadline so maybe someone can help me here. We have a few scripts that get launched through Shotgun, I updated one of them and it has an ‘import nuke’ statement at one point. When it goes through Deadline, it fails to import.
INFO: Execute in Shell: False
INFO: Invoking: Run Process
STDOUT: No module named nuke
What’s weird is that we have another script that also goes through Deadline/Shotgun and use the nuke module without issues. It also uses the same group and pool of slaves within Deadline.
Any ideas? thanks
It might be the environment isn’t being set to load Nuke? Dump os.environ before the import.
I wonder if another script is just working around the problem.
Deadline 10 these days should be impervious to weird settings of PYTHONHOME and PYTHONPATH so feel free to set those if it’ll help. Linux is especially tricky for this but you can copy the “deadlineclient.sh” script in “/etc/profile.d/” and add other environment options there. I wouldn’t edit the file directly though because the installer would overwrite it.
For the moment I was able to get the script working by appending the Nuke python path before my import statement:
try:
if sys.platform.startswith(‘linux’):
lin_path = env.path_fix(‘V:/tools/software/lin/core/nuke/nuke_11.2v1/lib/python2.7/site-packages/’)
sys.path.append(lin_path)
else:
sys.path.append(‘V:/tools/software/lin/core/nuke/nuke_11.2v1/lib/python2.7/site-packages/’)
import nuke
print(“imported nuke module successfully”)
except Exception as e:
print e
print 'Nuke python api not available. This is fatal.'
return 1
This probably isn’t the best solution for long-term so I’ll look into that profile.d folder, I do already see deadlineclient.sh in there.
Okay, sounds good! I’d definitely prefer Nuke being configured.
Often, the issue here is that accounts may have an export
for Nuke’s paths but the Launcher and then the Slave is started by init
and if a user wasn’t specified the Launcher will run as “root” who may not have those paths configured.
Thanks, would you know where I’d configure it for root? What you described is pretty much how these scripts run, the user just says ‘auto’.
Another question I had: How does the ‘Python Paths’ section under Configure Repository Options (super user mode) fit into all this?
Well, ideally the Slave isn’t running as root but the su
we run in the init script is going to run all the scripts in “/etc/profile.d/” before it starts up the Launcher so use “/etc/profile.d/deadlineclient.sh” as a base and add some other variables in there.