ExecuteScript | Import Error


#1

Hi,
I want to use a 3rd party library. For example, the Deadline Standalone API but it throws such an import error.

PS C:\Users\AdminTest\Desktop> & "C:\Program Files\Thinkbox\bin\deadlinecommand.exe" -executescript slaves_calc.py
Qt: Untested Windows version 10.0 detected!
Error: ImportError : No module named DeadlineConnect
  File "C:\Users\AdminTest\Desktop\slaves_calc.py", line 1, in <module>
    from Deadline.DeadlineConnect import DeadlineCon as Connect

I have added Deadline Standalone API library to C:\Program Files\Thinkbox\bin\pythonsync, C:\Program Files\Thinkbox\bin\Lib\site-packages here.

Thanks :slight_smile:


#2

Hi ,

The error your getting, is because your using the python standalone api in a python scripting context.

in a nut shell, if your using the standalone python scripting api, then us need a webservices node to communication with, you would just run:

python.exe slaves_calc.py

The path to the python standaone api would need to be in your pythonpath or sys.path.append() in your script.

You would only ever call :slight_smile:

"C:\Program Files\Thinkbox\bin\deadlinecommand.exe" -executescript

if you had written your code with the deadline python scripting api.

Confusing , Tell me about it…

The standalone python api docs can be found here:
https://docs.thinkboxsoftware.com/products/deadline/10.0/3_Python%20Reference/index.html

The deadline scripting here:
https://docs.thinkboxsoftware.com/products/deadline/10.0/2_Scripting%20Reference/index.html

Hope this helps.
Kym


#3

Thanks, but that’s not what I mean. I’ve already written the whole system with standalone api. But I need deadline scripting. I have to run with -executescript for it.


#4

The problem is they are mutually exclusive, you cant really mix them.
you could try to import the standalone api into a scripting session … but i wouldnt recommend it, sure its good for some situations.

@eamsler you have to have a good explanation why this is not the best way to work?


#5

I need. For example, I need to do a lot of work when the job starting. Send mail, log write, cost calculation etc.


#6

Hey guys,

The big issue with mixing them is that the namespaces collide and the standalone API is masked off after Python.net loads in the virtual modules from C#. Here’s some code for example:

import Deadline.DeadlineConnect as Thing1
import Deadline.Scripting as Thing2

Even with Deadline configured to use your site-packages you’ll see this:

c:\Program Files\Thinkbox\Deadline10\bin>deadlinecommand executescript C:\Users\me\Downloads\import-test.py
Qt: Untested Windows version 10.0 detected!
Error: ImportError : No module named DeadlineConnect
  File "C:\Users\me\Downloads\import-test.py", line 1, in <module>
    import Deadline.DeadlineConnect as Thing1

For how to add Python modules, you can check the docs here.

Update: You could do something sneaky like rename the “Deadline” folder in your site-packages to “DeadlineConnect”. That’ll at least fix the conflict, but all of your imports will be non-standard.