running terminal command from python 3.3
Question: i am trying to run wkhtmltopdf (a routine that convert an html to pdf:
<http://wkhtmltopdf.org>) command from python 3.3 (mac osx 10.7.5).

The routine works like a charm when directly run on terminal with the
following command:

    
    
    wkhtmltopdf http:google.com /Users/ME/Desktop/google.pdf
    

where http:google.com is the html that will be converted to pdf in the
destination file: /Users/ME/Desktop/google.pdf

However when calling the shell from python:

    
    
    import subprocess
    
    subprocess.call(["wkhtmltopdf http:google.com /Users/ME/Desktop/google.pdf"])
    

**i get:**

    
    
    > Traceback (most recent call last):   File "<pyshell#5>", line 1, in
    <module>
        subprocess.call(["wkhtmltopdf http:google.com /Users/thenoze/Desktop/google.pdf"])   File
    "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/subprocess.py",
    line 523, in call
        with Popen(*popenargs, **kwargs) as p:   File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/subprocess.py",
    line 824, in __init__
        restore_signals, start_new_session)   File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/subprocess.py",
    line 1448, in _execute_child
        raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'wkhtmltopdf http:google.com /Users/ME/Desktop/google.pdf'
    

\--> Any lead how to format my subprocess.call() ?


Answer: Separate the command line arguments as list items:

    
    
    subprocess.call(["wkhtmltopdf", "http:google.com", "/Users/ME/Desktop/google.pdf"])
    

Otherwise, `wkhtmltopdf ... google.pdf` is treated as a program path, instead
of `wkhtmltopdf`.

