Executing the Python script failed: NameError: name 'input_table' is not defined

Hi all,
I’m a new user of KNIME. I’d tried to create a workflow for calculating QED for drug design.
After, including the Python script,
from rdkit import Chem
from rdkit.Chem import Descriptors
from rdkit import rdBase, RDConfig
import sys, os
sys.path.append(os.path.join(RDConfig.RDContribDir, ‘SA_Score’))
import sascorer

qeds =
sas =
for mol in input_table[‘mol’]:
qeds.append(Descriptors.qed(mol))
sas.append(sascorer.calculatescore(mol))
output_table = input_table
output_table[‘qed’] = qeds
output_table[‘sa_score’] = sas
print (output_table.head ())

I’m getting the following error

“Executing the Python script failed: Traceback (most recent call last): File “”, line 10, in , NameError: name ‘input_table’ is not defined”
I’m using Python 3.9.16…
It seems I could not call input from knio.input_table[0] to python environment
Can you give suggestions to fix it?

Thanks

@gurudeeb_knime welcome to the KNIME forum. It seems your node is configured to expect an input table. You might have to provide one or delete the port:

You might want to read about the handling of the current python nodes.

2 Likes

Hi @gurudeeb_knime ,

additionly to @mlauber71 s correct answer, I suggest having a look at the node’s description: the very first link is KNIME Python Integration Guide
which should also answer most of the upcoming questions.
Also have a look inside the node for the Templates tab, which provides starting examples for scripts, where you only need to copy paste your code.

And please format code :slight_smile: you make it for your fellow helpers a lot easier.
Screenshot 2023-04-28 at 08.41.38

Best regards and happy scripting
Steffen

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.