How can I pass file names to external commands executed from Python?
Question: I am trying to execute a command inside a Python script:

    
    
    import subprocess
    output_process = 
       subprocess.Popen("javac -cp C:\Users\MyUsername\Desktop\htmlcleaner-2.2.jar Scrapping_lastfm.java",
                        shell=True, stdout=subprocess.PIPE)
    

But I am getting an error `package org.htmlcleaner does not exist`.

If I run the javac command independently, it executes fine..

My current working directry is `C:\Users\MyUsername`.


Answer: Try

    
    
    output_process = subprocess.Popen(["javac", "-cp", 
        "C:\Users\MyUsername\Desktop\htmlcleaner-2.2.jar", "Scrapping_lastfm.java"],
        shell=True, stdout=subprocess.PIPE, env={'ENVIRONMENTAL': '/variables/here'})
    

with whatever java-related environmental variables you have when you run
`javac` normally as items in the `env` dictionary. asgs suggests you need
`CLASSPATH`.

You don't have to split the command up into a list I just did that to make it
easier to see the whole thing.

