Python Script Macro Error

ijm
python
macro
Tags: #<Tag:0x00007fb87cff4470> #<Tag:0x00007fb87cff4330> #<Tag:0x00007fb87cff41f0>

#1

Hi,

I have no experience with coding or anything. However, I need to run a python script that is part of a project. The python script keeps returning this error:

I was able to find this ijm file that the python script seems to be using. Here is what I found:

arg = getArgument();
argA = split(arg, ";");

requires("1.51d");
	  
dir1 = argA[0]+"/";
dir2 = argA[1]+"/";
list = getFileList(dir1);
setBatchMode(true);
      
for (i=0; i<list.length; i++) {
	open(dir1+list[i]);
	if (endsWith(list[i], '.png')) {
		showProgress(i, list.length);
		run("Auto Threshold", "method=Otsu white show");
		saveAs("png", dir2+list[i]); 
		close();
	}
	else {
		print("This is not Image File : "+dir1+list[i]);        
	}
}

Would someone be able to troubleshoot and tell me how to fix this issue?


#2

The error message suggests that the passed-in argument string is either not correct, or not being split into pieces properly.

Try adding print statements to the macro. Right after the arg = line you can add a line that says print(arg); to show the argument that was passed in. According to the calling Python script, it is supposed to have a semicolon (;) character in there, which then gets split. You can then add print(argA[0]); immediately after the argA = line, to see what the first token of the split arguments looks like.