Mmm. Are you setting the enviornment in the event script? Here’s an example from DraftTileAssembler.py:
def DraftAutoUpdate( self, localPath ):
updateNeeded = True
draftPathComponents = GetDraftPathComponents()
localFile = os.path.join( localPath, "Version" )
repoFile = RepositoryUtils.GetRepositoryFilePath( os.path.join( draftPathComponents, "Version" ), False )
if not os.path.exists( repoFile ):
self.FailRender( "ERROR: Draft was not found in the Deadline Repository!" )
if ( os.path.exists( localPath ) and os.path.isfile( localFile ) and os.path.isfile( repoFile ) ):
if filecmp.cmp(localFile, repoFile):
updateNeeded = False
elif not os.path.exists( localPath ):
self.LogInfo( "Creating local Draft directory..." )
os.makedirs( localPath )
if ( updateNeeded ):
repoPath = RepositoryUtils.GetRepositoryPath( draftPathComponents, False )
self.LogInfo( "Draft upgrade detected, copying updated files..." )
for filePath in Directory.GetFiles( repoPath ):
fileName = Path.GetFileName( filePath )
self.LogInfo( "Copying '%s'..." % fileName )
File.Copy( filePath, Path.Combine(localPath, fileName), True )
self.LogInfo( "Draft update completed!" )
... some other function:
self.DraftAutoUpdate( draftLocalPath )
if SystemUtils.IsRunningOnWindows():
draftLibrary = Path.Combine( draftLocalPath, "Draft.pyd" )
else:
draftLibrary = Path.Combine( draftLocalPath, "Draft.so" )
if not os.path.isfile( draftLibrary ):
self.FailRender( "Could not find local Draft installation." )
else:
self.LogInfo( "Found Draft python module at: '%s'" % draftLibrary )
self.DraftDirectory = draftLocalPath
#preserve existing env vars by appending/prepending
newPythonPath = self.DraftDirectory
if Environment.GetEnvironmentVariable( "PYTHONPATH" ) != None:
newPythonPath = newPythonPath + Path.PathSeparator + Environment.GetEnvironmentVariable( "PYTHONPATH" )
newMagickPath = self.DraftDirectory
if Environment.GetEnvironmentVariable( "MAGICK_CONFIGURE_PATH" ) != None:
#give locally set MAGICK path priority over the Draft one
newMagickPath = Environment.GetEnvironmentVariable( "MAGICK_CONFIGURE_PATH" ) + Path.PathSeparator + newMagickPath
self.SetEnvironmentVariable( 'PYTHONPATH', newPythonPath )
self.SetEnvironmentVariable( 'MAGICK_CONFIGURE_PATH', newMagickPath )
Sorry if that’s a bit overwhelming. It may be easier for you to do something like this:
import os
path_to_draft = 'P:\DeadlineRepository10\draft3\Windows\64bit'
os.environ['PYTHONPATH'] = path_to_draft
os.environ['MAGICK_CONFIGURE_PATH'] = path_to_draft
One reason it may not import is if the event is running in Python2 mode. The libraries are built to target very specific versions of Python (3.7 and 2.7) any other major.minor like Python 3.10 will fail to import the library.