Search code examples
pythonsubprocessdocopt

TypeError: execv() arg 2 must contain only strings using docopt


I am running into following error while passing arguments. Can anyone help me identify this problem? I'm passing instructions to my function in terminal like this:

python makeQuicktime.py -i /Volumes/P003A/TM_Cloud/Nagrania/Karta_04/XDROOT/Clip/D004C010_141026MM.MXF -f 25 -c prores

This is the main function - as you see I'v tried to pass argument --codec as string:

if __name__ == "__main__":
    args = docopt(__doc__, version='makeQuicktime 0.0.1')
    print args
    cmd_args = ""
    codec=str(args['--codec'])

    makeQuicktime( args['--input'], fps=args['--fps'], codec=str(args['--codec']) )

    os._exit(0)

The part of other function that this code is running (makeProRes, line 110 is the output variable):

subprocess.call([FFMPEG_PATH, 'i', input,
    '-start_number', start_frame, '-r', fps,
    '-c:v', 'prores',
    '-profile:v', '2',
    '-c:a', 'copy',
    '-threads', cpus,
    output
  ])

Error:

Traceback (most recent call last):
  File "makeQuicktime.py", line 123, in <module>
    makeQuicktime( args['--input'], fps=args['--fps'], codec=str(args['--codec']) )
  File "makeQuicktime.py", line 53, in makeQuicktime
    makeProRes(1, input, fps, output)
  File "makeQuicktime.py", line 110, in makeProRes
    output
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 524, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1308, in _execute_child
    raise child_exception
TypeError: execv() arg 2 must contain only strings

Solution

  • One of start_frame, fps, or cpus is a number rather than a string. When you find out which, enclose it in str() to convert it.