Python modules for monitor scripts?

I’m writing a monitor script with a dependency on a Python package not included with Deadline, and Monitor is erroring out on the import line in the script. Here’s what I’ve done:

I installed the package to the repository/custom/python_modules/site-packages folder with

pip install myPythonPackage --ignore-installed --target="\\repositoryShare\DeadlineRepository10\custom\python_modules\site-packages"

and verified the package is now in that location and that that path is in my repo options Python Settings.

In the console I get

FranticX.Scripting.PythonNetException: ModuleNotFoundError : No module named 'myPythonPackage'

When I run it however. What am I doing wrong?

Could you print from within the script whether the site-packages folder is in sys.path?
Haven’t used this mechanism but sounds cool.

You might also need to restart your Monitor to force it to pull in the additional modules you’ve listed in the Monitor under Tools → Configure Repository Options → Python Settings.

I’d also try adding the myPythonPackage folder directly in the Python Settings versus just \\repositoryShare\DeadlineRepository10\custom\python_modules like I’m assuming you’ve got now. It could be that the import isn’t properly diving into the directory.

Adding the specific path to the module in Deadline’s Python path helped, but immediately became a very similar DLL loading error.

This appears to be down to the specific Python package I’m trying to use - pywin32. That package includes DLLs that the install script wants to write to the Windows folder and I don’t have admin rights on the repository machine.

Could you show the error? A dll load error often means that you are missing a dependency (e.g. a needed version of msvc redistributable).

OK, I managed to get pywin32 working as follows:

import os, sys, errno
# appending system PATH so pywin32 can find its DLLs
# since they aren't installed to \system32
pywin32_dll_path = os.path.abspath(r'\\[repository share]\DeadlineRepository10\custom\python_modules\site-packages\pywin32_system32')
os.environ['PATH'] = pywin32_dll_path + ";" + os.environ['PATH']
from win32com.client import Dispatch 

THEN the following paths needed to be added to the repository’s search path to resolve all the module dependencies:

//RepositoryShare/DeadlineRepository10/custom/python_modules/site-packages/win32
//RepositoryShare/DeadlineRepository10/custom/python_modules/site-packages/win32/lib
2 Likes