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!

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
>>>help(os.execv)
#displays info

in your case it shows this:

Help on built-in function execv in module nt:

execv(...)
    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?

in that case you parse no arguments by giving it an empty tuple.
So it would be

os.execv("path here",())

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.....

You should try with a spawn instead of exec to see if it gives better results, or more information.

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

HTH