Calling an executable Processing script via python gives a classpath error.

edited May 2016 in Python Mode


I am trying to execute a processing executable via subprocess in python. When the exe is ran from the command line everything is fine. When called via python it says it cant find the class. Now normally if this was a java file i could call the script with the -classpath option and set the classpath on the fly, but as its a .exe i cant do this. Setting the classpath variable in windows doesnt seem to help either.

Here is the script. It just converts an image passed as an argument and saves it to gray scale.

    PImage img;
    void setup() {
      if (args.length != 0) {
        img = loadImage(args[0]);
    void draw() {

here is python code i am using to call it

    import subprocess
    args = ['D:\\Glitch Art\\Processing Scripts\\image_args_test\\application.windows32\\image_args_test.exe',\
            'D:\\Glitch Art\\Processing Scripts\\image_args_test\\application.windows32\\test.jpg']
    if __name__ == "__main__":
        child = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdoutdata, stderrdata = child.communicate()

and here is the error

Error: Could not find or load main class image_args_test

I know its a classpath problem... but how do i set this on the fly when calling an executable?


  • A quick google search results in this site. If I remember right, what you are doing is to launch java programs. The .exe produced by Processing does that for you, so you obviously failed.
    For this to work, use a java program that imports the processing library.

  • Thanks But I do know how to run a exe in python. I can run any exe with subprocess. And that java exe runs ok when ran from the command line.

  • please don't post questions multiple times.

  • edited May 2016

    Then you could just run it as .exe.

  • Thanks but im not sure how this can help me. It can run it fine directly from the command line giving it arguments. Im look at how to fix the classpath when the .exe is executed from python.

  • edited May 2016

    My Python skills are rather limited.
    Using a simple java program, however, I can get the results you want.
    My best idea would be (I don't know how, but I hope you do) to create a text file (through python program) containing all the arguments, then let the Processing sketch do the work by reading the text file, getting the arguments and then deleting the text file before closing.

  • But I should thank you, as I solved a problem just now because of this question.

Sign In or Register to comment.