importing Draft Fails...

Can you guys help me with this one? I have a event that I wrote that one of the tasks is makes a thumbnail which is based off of your shotgun code. The problem is that when I import Draft it fails and I don’t see where the problem is…

Here is the source:
draftRepoPath = Path.Combine( RepositoryUtils.GetRootDirectory(), “Draft” )

	if SystemUtils.IsRunningOnMac():
		draftRepoPath = Path.Combine( draftRepoPath, "Mac" )
	else:
		if SystemUtils.IsRunningOnLinux():
			draftRepoPath = Path.Combine( draftRepoPath, "Linux" )
		else:
			draftRepoPath = Path.Combine( draftRepoPath, "Windows" )
		
		if SystemUtils.Is64Bit():
			draftRepoPath = Path.Combine( draftRepoPath, "64bit" )
		else:
			draftRepoPath = Path.Combine( draftRepoPath, "32bit" )
	
	#import Draft and do the actual conversion
	ClientUtils.LogText( "Appending '%s' to Python search path" % draftRepoPath )
	if not str(draftRepoPath) in sys.path:
		sys.path.append( str(draftRepoPath) )
		#print sys.path
	ClientUtils.LogText( "SysPath: '%s'" % sys.path )	
	
	ClientUtils.LogText( "Importing Draft to perform Thumbnail conversion..."  )
	try:
		import Draft
	except:
		ClientUtils.LogText("Failed to import Draft!")

And Here’s the output:
Appending ‘R:\Repository\Draft\Windows\64bit’ to Python search path
SysPath: ‘[‘C:\Program Files\Thinkbox\Deadline\python\2.6.7\x64\lib’, ‘C:\Program Files\Thinkbox\Deadline\python\2.6.7\x64\Dlls’, ‘C:\Program Files\Thinkbox\Deadline\python\2.6.7\x64\python26.zip’, ‘C:\Windows\system32’, ‘C:\Program Files\Thinkbox\Deadline\bin’, ‘C:\Program Files\Thinkbox\Deadline\python\2.6.7\x64’, ‘C:\Program Files\Thinkbox\Deadline\python\2.6.7\x64\lib\site-packages’, ‘C:\Windows\Microsoft.NET\Framework64\v2.0.50727\’, ‘R:\Repository\Draft\Windows\64bit’]’
Importing Draft to perform Thumbnail conversion…
Failed to import Draft!

Any ideas?

Thanks,
Andrew

Hey Andrew,

A few things:

  1. Is this a Python.NET script? Draft will only be loaded by Python.NET scripts because it is a cPython module. You can make your script a Python.NET script by making this your first line:
#Python.NET
  1. Do you guys have licenses for Draft? If not, shoot an email to sales@thinkboxsoftware.com to get your licenses. A missing license will prevent the Draft module from being loaded.

  2. Finally, it would also help to see what the actual import error is. You can do this by importing traceback:

import traceback

Then you can print out the exception in your except block:

try:
    import Draft
except:
    ClientUtils.LogText("Failed to import Draft!")
    ClientUtils.LogText(traceback.format_exc())

Cheers,

  • Ryan

Hey Ryan,

We do have licences and the file has the #Python.NET as the first line. Here’s the result coming from the traceback:

Traceback (most recent call last):
File “none”, line 131, in ConvertThumbnail
ImportError: DLL load failed: The specified module could not be found.

not real descriptive… The path looks fine so I’m not sure where the issue is. Can it be that it’s loading it from a network drive?

Draft itself is actually working fine if I submit a job to it’s plugin.

-Andrew

Hmm, I wouldn’t think being on a network drive would be an issue, but a quick way to determine of that’s the issue is to copy Draft from the network path to a local path, and do the import from there. If that still doesn’t work, I’ll point the Draft guys at this to see if they have any ideas.

Cheers,

  • Ryan

Hey Ryan,

So I tried putting it local and hard coding the path addition and received the same result…

Here’s the outut:

Succesfully published to NIM. Appending 'R:\Repository\Draft\Windows\64bit' to Python search path SysPath: '['C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\lib', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\Dlls', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\python26.zip', 'C:\\Windows\\system32', 'C:\\Program Files\\Thinkbox\\Deadline\\bin', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\lib\\site-packages', 'C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\', 'R:\\Repository\\Draft\\Windows\\64bit', 'C:\\Program Files\\Thinkbox\\Deadline\\Draft\\Windows\\64bit']' Importing Draft to perform Thumbnail conversion... Failed to import Draft! Traceback (most recent call last): File "none", line 132, in ConvertThumbnail ImportError: DLL load failed: The specified module could not be found.

Could it have anything to do with the order that it is being loaded? I am loading it after a bunch of other libraries load by default…

Hmm, I’m not sure. I’ve forwarded this thread link to the Draft guys to see if they have any ideas.

Cheers,

  • Ryan

I just noticed that the R: path is still in sys.path, and it’s listed before the local path. Can you try removing the R: path from the system path to see if that makes a difference?

Hey Ryan,

Same result…

SysPath: '['C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\lib', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\Dlls', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\python26.zip', 'C:\\Program Files\\Thinkbox\\Deadline\\bin', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\lib\\site-packages', 'C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\', 'C:\\Program Files\\Thinkbox\\Deadline\\Draft\\Windows\\64bit']' Importing Draft to perform Thumbnail conversion... Failed to import Draft! Traceback (most recent call last): File "none", line 134, in ConvertThumbnail ImportError: DLL load failed: The specified module could not be found.

I keep thinking I must be doing something dumb and checking it back against the shotgun example but I don’t see anywhere it’s going wrong. I even tried loading before all of my other libraries and no difference. Unfortunately I don’t have shotgun to see if that script actually works.

Could you possibly upload your full script? Then we could try it here.

PM

Thanks! I took your script, and the only change I made was the following to make it work on my end:

  1. Commented out the first 2 lines in the init constructor.
  2. Rename the original OnJobFinished function to OnJobFinished2.
  3. Created a new OnJobFinished function that looked like this:
   def OnJobFinished( self, job ):
      outputPath = "C:\\test.png"
      format = "jpeg"
      
      try:
         convertedThumb = self.ConvertThumbnail( outputPath, format )
      except:
         ClientUtils.LogText( "WARNING: Failed to convert frame using Draft; uploading original instead." )

I then marked the tasks for a job as complete to trigger the event, and it worked fine. The Draft module was imported, and a test.jpeg file was created.

The only other thing I can think to try is to insert the Draft path at the beginning of sys.path, instead of appending it to the end, to see if that helps.

Cheers,

  • Ryan

Hrm… So I did exactly what you said and still no go… Anything else you can think of… is it looking for something more than Draft.pyd?

made all the changes including

sys.path.insert(0,str(draftRepoPath) )
Appending 'R:\Repository\Draft\Windows\64bit' to Python search path
SysPath: '['R:\\Repository\\Draft\\Windows\\64bit', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\lib', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\Dlls', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\python26.zip', 'C:\\Program Files\\Thinkbox\\Deadline\\bin', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64', 'C:\\Program Files\\Thinkbox\\Deadline\\python\\2.6.7\\x64\\lib\\site-packages', 'C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\']'
Importing Draft to perform Thumbnail conversion...
Failed to import Draft!
Traceback (most recent call last):
  File "none", line 133, in ConvertThumbnail
ImportError: DLL load failed: The specified module could not be found.

What files do you have in your Draft\Windows\64bit folder? In mine, I have:

avcodec-54.dll avformat-54.dll avutil-51.dll boost_python-2_6-vc80-mt-1_46_1.dll colors.xml Draft.pyd DraftParamParser.py libx264-125.dll SourceSansPro-Regular.otf swscale-2.dll tbb.dll type.xml Version

Cheers,
Andrea

Just another thing to try too, try changing working directories to the Draft folder using ‘os.chdir’ before importing, see if that makes a difference:

import os os.chdir( r"R:\Repository\Draft\Windows\64bit" )

So I do have some different files than what you listed…

avcodec-53.dll
avformat-53.dll
colors.xml
Draft.pyd
DraftParamParser.py
libx264-119.dll
libx264-120.dll
libx264-124.dll
libx264-125.dll
SourceSansPro-Regular.otf
swscale-2.dll
tbb.dll
type.xml
Version

Is it a version problem? Maybe my repository didn’t update properly on my last update???

Jon, I tried your suggestion and I’m still receiving the same error. I’m starting to think that maybe it is a problem with my last deadline repository update

FIXED!!!

It was a problem with my repository install… I was missing files in my Draft folder.

I just did a fresh install on another drive and realized I didn’t have all the files I needed. Here’s what happened when I did the Repository install and maybe this will explain it. I tried to install over our linux mounted drive from a windows box and it kept hanging and failing out. So, I downloaded the linux repository installer and installed it directly from the linux box. Repository installed no problem… But it appears there was a problem… Not sure what else would be wrong or missing but everything else seems to be working normally.

Thanks everyone!
Andrew

I’m glad to hear it’s working now! (Paul pointed out that my version of Draft appears to be a bit out of date, but the list was at least good enough to figure out there were missing files.)

Cheers,
Andrea