hi all, assuming a path of for example "C:\Python24\development\radar\nra.py" where 'nra.py' is the executable file, could someone please show me the exact syntax for a call to os.execv() in order to run the file 'nra.py'. (nra.py requires no arguments when called. )
Thanks in advance!

9 Years
Discussion Span
Last Post by jlm699

If you want help for syntax. There is an easy way to do it. you go something like this for your example:

# just type each line in the interpreter
>>> import os
#displays info

in your case it shows this:

Help on built-in function execv in module nt:

    execv(path, args)
    Execute an executable path with arguments, replacing current process.
            path: path of executable file
            args: tuple or list of strings

Hope that helps


Thanks paulthom12345, I think perhaps my initial post was badly worded! Sorry for that. I realise that the call to os.execv requires two arguments, and I'm fairly sure the 'path' argument I pass is ok. Its what is required in the 'args' list/tuple that I cannot get right. Any thoughts?


Ok, have done that. I, wrongly, assumed that getting a 'Exec format error' meant there was a problem with one or other of the passed arguments. Having done a little more searching I now think it means that the program was not able to be executed. I've a feeling that the 'args' argument has to contain some string(s) which are not necessarily arguments for the program to be executed. If anyone out there knows.....


I think that when trying to run a python program you should be doing

os.execv( 'C:\\Python24\\python.exe', 'C:\\Python24\\development\\radar\\nra.py')

ie, you're not actually executing the program, you're executing Python and asking it to interpret your script nra.py


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.