"Function to ignore python environment..."

This is an error in that’s started popping up in an automated script to requeue jobs. We’ve just started moving on to setting up the real repository on the server and it’s surfaced. Basically I have a script running that performs multiple subprocess calls to deadline, but the specific requeue one seems to be triggering this.

[code]subprocess.call([deadlineCommand, “-RequeueJob”, myID])

Function to ignore python environment is not defined in the native python library
ImportError: No module named site[/code]

As I said, I have run other queries in this same script that get and set various settings on jobs but this is the only one triggering the error. The error is absent when I comment out that line so I know that’s the trouble.
I’ve checked and my python installation can import the site module fine when I run it. (both my local machine and the server) I also checked my environment variables as described in the top answer here

The other odd thing is that the requeueing does work in spite of the error. At the moment the only problem I can see is that it doesn’t give the message indicating that the job was requeued. However it still notifies me fine about ExtraInfo fields being set before and after the requeueing.
So any ideas what this might be?

Is this Python script executed within the Deadline environment or with dpython.exe or completely externally?

If its within the Deadline environment, can you try using ProcessUtils class instead of subprocess?
docs.thinkboxsoftware.com/produc … utils.html
or
docs.thinkboxsoftware.com/produc … utils.html
depending on perspective your executing this script?

It’s completely external, there’s a system that has triggers at certain key events that we’re using so it can’t be internal.
I realised I might not have made it clear also, this worked fine without any notice like this when referring to a local repository. I had a sandbox set up, with both the trigger script and repository on my machine and it ran smoothly, it’s now that the repository is on a server separate to the trigger script that it has arisen.

Hmmm…strange. It seems to be a misconfiguration of your python environment on the machine which is triggering your python script.
I assume your ‘local’ machine and the new machine ‘triggering’ the python script are not the same machine? Can you compare environments to see if anything stands out? I assume if Python is just been installed, that the machine has been rebooted at least once? If you compare the results of typing “set” in a command shell on both Windows machines, does anything stand out, with regard Python configuration? PYTHONHOME and/or PYTHONPATH? This is Python v2.7 x64bit?

That actually likely is it, I had some issues with environment variables before because I needed both a 64 and 32 bit copy of Python for different purposes.
I’m on Windows and needed to set up the 32 bit Python to be able to run scripts as a service from the command prompt. And for some reason, that wouldn’t run for me when I was setting the PYTHONHOME environment variable, it would just give errors about win32 modules missing.

Here’s the relevant results, (I removed unrelated paths for readability)
Local machine

PATH=C:\Python27;C:\Python27\Lib\site-packages;C:\Python27\Scripts;C:\Python27(32Bit);C:\Python27(32Bit)\Lib\site-packages;C:\Python27(32Bit)\Scripts;C:\Program Files\Thinkbox\Deadline7\bin PYTHONPATH=C:\Python27(32Bit);C:\Python27(32Bit)\Lib\site-packages;C:\Python27(32Bit)\Scripts;C:\Python27;C:\Python27\Lib\site-packages;C:\Python27\Scripts;C:\DeadlineRepository7\draft\Windows\64bit

Server

Path=D:\Python27 PYTHONHOME=D:\Python27 PYTHONPATH=D:\Python27\Lib

It’s probably a mess to resolve unless something springs to mind as a problem. If you do suspect it’s environment variable based then it’s likely to be limited to my machine (as the server has the system set up without the issues I had on my computer) so I’m going to test the server itself running this script soon and see if it might be a problem there as well.

Perhaps a solution to help you get your paths organised is to either use Python’s virtualenv’s or add the extra paths that might be needed at the top of your script?
stackoverflow.com/questions/1225 … -in-python

Sounds like there is a mismatch in Deadline’s python installation. We made changes to the version of python that ships with Deadline during the 7.0 beta program, and this error message indicates that you have a newer version of the Deadline applications, but an older version of python on your machine.

Is it possible that your sandboxed environment had a beta version of Deadline 7.0 installed, but your server has the release version of 7.0 installed? If so, running the latest Deadline Client installer on your machine should fix the problem.

Cheers,
Ryan

I don’t believe we installed the beta, no.
I opened dpython.exe (from the Deadline7 bin) on both machines and got the same opening line at the top of the windows:
“Python 2.7.8 (default, Sep 22 2014, 15:54:24) [MSC v.1500 64 bit (AMD64)] on win32”

Do you still think it’s worth attempting a reinstall of Deadline on this machine or does that rule out that cause?

I’ll look into that, thanks Mike!

I think it’s still worth running the client installer again. It only takes a few minutes, and if it doesn’t help, then at least we can rule that out. :slight_smile:

Cheers,
Ryan

Actually the server is performing it even worse when it’s all happening on the server.
I might need to clarify exactly how the process was and is working because it’s a bit complicated just explaining it by text.

There’s a trigger script running and it calls deadline, the initial set up I had was both are on my machine:
Trigger => Deadline repository
My machine => My machine

Then the real repository was set up on the server, that’s when the errors above surfaced:
Trigger => Deadline repository
My machine => Server

And just now, I moved the triggering script onto the server to test that out, and it’s producing a more verbose error (see below)
Trigger => Deadline repository
Server => Server

INFO:plugin.RequeueNewShotVersion.requeueNewVersion:Job ID found: 54eddf0cedaac91d9cb9db59 Set ExtraInfo9 to 6733 Function to ignore python environment is not defined in the native python library System.DllNotFoundException: Unable to load DLL 'python27': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at Python.Runtime.Runtime.Py_SetPythonHome(IntPtr home) at FranticX.Scripting.PythonNetScriptEngine.Initialize(String home, String programName) Function to ignore python environment is not defined in the native python library System.DllNotFoundException: Unable to load DLL 'python27': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at Python.Runtime.Runtime.Py_SetPythonHome(IntPtr home) at FranticX.Scripting.PythonNetScriptEngine.Initialize(String home, String programName) Resumed job 54eddf0cedaac91d9cb9db59 Set ExtraInfo3 to pr135_sc052_v01

Yet again, the behaviour under the hood functions entirely as expected but it consistently spits out this error. I guess this means something on the server itself is actually the issue. And the server literally only just had Deadline7 installed yesterday so it surely can’t need a reinstall?

I was working a bit more on trying to solve this. I did discover that the environment variable for deadlinecommand itself was set to the path for the old repository instead of the new one, so I adjusted that and it’s now back to the original error that’s just
“ImportError: No module named site”

I’m stumped at this point. The module definitely exists, the environment variables are set properly and this is a fresh install of a repository.
I did try running DeadlineCommand with -RequeueJob and some other commands from the commandline and they don’t throw the error, they just behave normally. So for whatever reason it is specifically this one script and only this call to DeadlineCommand. I tried to look up if subprocess.call might have been the source of the issue but I didn’t find any results that would help in this situation, so it definitely seems like it has to do with what Deadline does once the call is made.

Hi Gary,
Hmm, very strange. If your sure that all your setup is running Deadline v7.0.2.3, then I think it might be best if you drop an email to support@thinkboxsoftware.com and our support team can organise a remote session with you and see if anything stands out on screen as the root cause here.

Thanks Mike, I’ve sent an email off now.