I'm trying to integrate some OpenEye tools into KNIME using Python scripts. I installed OpenEye's toolkits as Python modules in an Anaconda environment. I've set in KNIME the path to the python executable within this environment.
To call the OpenEye functions using Python outside KNIME I just have to use, e.g.:
from openeye.oechem import * mol = OEGraphMol()
And that works just fine, and "mol" is this object: <openeye.oechem.OEGraphMol; proxy of <Swig Object of type 'OEGraphMolWrapper *' at 0x7f94296cbae0> >
However, for calling the toolkit to KNIME's Python snippet I have to call the modules in sequence to not get errors:
from openeye import oechem
from openeye.oechem import *
But, if I now run OEGraphMol(), or openeye.oechem.OEGraphMol() or oechem.OEGraphMol(), it does not find the function. Also, using dir(openeye.oechem), I do not get the functions. I think it is because of them being SWIG objects, but I think there is no way around using the SWIG objects in OpenEye's toolkits. Is there something I could try?
what the Python integration basically does is running the executable that you have set in Preferences→KNIME→Python and executing the source code via exec().
Please check the following:
- Make sure you are using the correct executable (it should be something like <anaconda-path>/envs/<env-name>/bin/python)
- Check that you have set the path in KNIME→Python (not KNIME→Python Scripting) and that you are using the nodes in /Scripting/Python (not Community Nodes/Python Scripting)
- Check if the modules you are using need specific environment variables. If yes then you could set them by using a script. See here for details.
Maybe one of these points can fix the problem you are having.