Why is the subprocess throwing an OSError here?

I wrote my own module, mainly processing the file field for the django site. After you came across some things related to mod_wsgi (resolved by updating to 3.3), I got my code to run. After all the necessary imports, before defining any classes or functions, I check for the presence of sox, audio communication for the important functions of my modules:

sox = 'path/to/sox' test=subprocess.Popen([sox,'-h'], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) error=test.communicate()[1] if error: raise EnvironmentError((1,'Sox not installed properly'),) 

Everything went perfectly. Now I updated ubuntu from 8.04 to 10.04, and the code breaks in the call line of the .Popen subprocess, causing the following error message:

 File "/usr/lib/python2.6/subprocess.py", line 1139, in _execute_child raise child_exception OSError: [Errno 8] Exec format error 

I have already looked for sox execution rights, I have no other idea where to look for a solution to this. Is it possible to restrict subprocess execution rights? Any hints what can be done here?

+6
python django ubuntu mod-wsgi
source share
3 answers

A tip from Apala solved the problem. Remember to try different versions of sox if the same thing happens again. Even if sox is working on the command line, it can cause problems with the subprocess.

+1
source share

Try executing sox as the same user as your django wsgi process.

It is possible that this binary file is not executable by this user or that during the upgrade from 8.04 to 10.04 you lost the kernel flag, which allows certain binary types to be executed.

+1
source share

If you are working on Linux and get "OSError: [Errno 8] Exec format error" - check if the kernel and the executable file for the same platform are 32 bits and 64 bits. uname -a and file <executable path> will do the trick. This was my decision (and this page is the first hit of this error).

+1
source share

All Articles