JPython error?? [SOLVED - work-around]

The workflow I have in place is very simple. I have a File Reader (configured to read the iris data set in the Examples folder) connected to a JPython Script 1:1 (no modifications) linked to an Interactive Table. This is just to test the ability to get JPython to work. When I run the project, I get the following errors in the Console output:

*** Welcome to KNIME v1.2.1 - the Konstanz Information Miner ***
*** Copyright, 2003-2007, Uni Konstanz and KNIME GmbH, Germany ***
Log file is located at: C:\Program Files\knime_1.2.1\workspace\.metadata\knime\knime.log
WARN File Reader Configure failed: No Settings available.
ERROR PythonScriptNodeModel Traceback (innermost last):
File "<>", line 51, in ?

ERROR PythonScriptNodeModel java.lang.IllegalArgumentException: Cell count in row "Row1" is not equal to length of column names array: 5 vs. 6


at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.python.core.PyReflectedFunction.__call__(

at org.python.core.PyMethod.__call__(

at org.python.core.PyObject.__call__(

at org.python.core.PyInstance.invoke(

at org.python.pycode._pyx0.f$0(<>:51)

at org.python.pycode._pyx0.call_function(<>)



at org.python.core.Py.runCode(

at org.python.core.Py.exec(

at org.python.util.PythonInterpreter.exec(

at org.knime.ext.jython.PythonScriptNodeModel.execute(

at org.knime.core.node.NodeModel.executeModel(

at org.knime.core.node.Node.execute(

at org.knime.core.node.workflow.NodeContainer$

at java.util.concurrent.Executors$ Source)

at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

at Source)

at org.knime.core.util.ThreadPool$

ERROR PythonScriptNodeModel java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cell count in row "Row1" is not equal to length of column names array: 5 vs. 6

ERROR PythonScriptNodeModel null
from import *
from import *
from import *
from org.knime.base import *

def val(colname, rowinstance, inport=0) :
__dts = 0
if inport == 0:
__dts = inData0.getDataTableSpec()
__dts = inData1.getDataTableSpec()

index = __dts.findColumnIndex(colname)
cellType = __dts.getColumnSpec(colname).getType().toString()
cellValue = rowinstance.getCell(index)
stringCellValue = str(cellValue)

if cellType == "DoubleCell":
return float(stringCellValue)
elif cellType == "IntCell":
return int(stringCellValue)
return stringCellValue

## Available scripting variables:
## inData0 - input DataTable 0
## outContainer - container housing output DataTable
## Example starter script:
## dts = inData0.getDataTableSpec()
## inputColumnIndex= dts.findColumnIndex("input_column_name")
## iterator = inData0.iterator()
## while iterator.hasNext():
## row =
## cell = row.getCell(inputColumnIndex)
## newStringCell = StringCell("some string")
## newIntCell = IntCell(100)
## newDoubleCell = DoubleCell(99.9)
## newRow = AppendedColumnRow(row, [newStringCell, newIntCell, newDoubleCell])
## outContainer.addRowToTable(newRow)
## Default script:
iterator = inData0.iterator()
while iterator.hasNext():
row =

ERROR PythonScriptNodeModel
ERROR JPython Script 1:1 Execute failed
ERROR JPython Script 1:1

Hello Kirk,

yes there is a bug in the JPhython node. As the error message implies, the definition of the output DataTableSpec does not match the DataTableSpec from the execution of the script.

This output DataTableSpec is defined in the dialog of the JPhython node in the 'Script output' tab. This dialog adds a default output column to the DataTableSpec. This is why you get a column names array of length 6 vs. the iris-data cell count of 5.

We have identified and fixed this bug and try to integrate that in one of the next versions. A workaround for now is to open the dialog, select this default column and press the 'Remove Output Column' button.



Thank you for your prompt response. I have attempted the work-around and it indeed fixes the problem.