python scripting

Hi KNIMERs
Can anyone give me a pointer as how to use the python scripting node I keep getting this error:
Executed command: python C:\KNIME\plugins\org.knime.python2_3.5.0.v201712011355\py\PythonKernelTester.py 2.7.0
Could not find python executable at the given location: python

Although I’ve set my preferences to point to a python.exe in the python scripting panel.
thoughts?
cheers,
mike

Hi @mazzo -

You might find this guide to setting up Python useful. Note that it’s Anaconda specific, though:

https://www.knime.com/blog/setting-up-the-knime-python-extension-revisited-for-python-30-and-20

Hi,
Ok - realised that you had to create a new node, because the current one doesn’t detect changes in python paths.
So I changed the path, created a new node and it worked…
Now got another bug:

ERROR Python Script (1⇒1) 6:568:502:0:451 Execute failed: Traceback (most recent call last):
File “C:\KNIME\plugins\org.knime.python2_3.5.0.v201712011355\py\PythonKernel.py”, line 491, in execute
exec(source_code, self._exec_env, self._exec_env)
File “”, line 22, in
File “C:\a3\envs\knime_keras\lib\site-packages\pandas\core\frame.py”, line 404, in init
raise ValueError(‘DataFrame constructor not properly called!’)
ValueError: DataFrame constructor not properly called!

hmmm?

./mike

Hi,
some context, this is from the 3Dechem recent publication Figure 4:

The Python code is below

import math as m
import pandas as pd
import numpy as np
import csv
raws= input_table[‘Sum(similarity)’]

raws = Raw scores

target= input_table[‘target__name’]
ntarg = len(set(target))

add ntarg manually? - bit of a pain -changed

ns1s2 = input_table[‘Count(ingredient__cmpd__chemblid)’]

size of set1*set2

zs = (raws - 0.000424ns1s2)/(0.00449(ns1s2**0.665))

ZScore following Shochet http://www.nature.com/nbt/journal/v25/n2/extref/nbt1284-S13.pdf supp info

x = -np.exp((-zs*np.pi)/np.sqrt(6.0)-0.577215665)

needed for Taylor expansion used to approximate PZ below

where 0.577215665 is an approx for Г’(1), the Euler-Mascheroni constant

pz = -(x + (xx)/2.0 + xxx/6.0)
e = (pz
ntarg*ntarg)
#E-value
nearesttarget=input_table[‘target__name’]
result = {‘nearesttarget’:nearesttarget,‘ns1s2’:ns1s2.astype(float),‘raw-score’:raws,‘z-score’:zs,‘E-value’:e}
pyOut = pd.DataFrame(result.values(),result.keys()).T

not needed print if do in KNIME, uncomment to run/check/debag

print pyOut

pyOut.to_csv(‘C:/Windows/ubuntuse/work/BioAxis/cmbi/value010615_48atestfixnew1.csv’, sep=’\t’, encoding=‘utf-8’)

output_table = pyOut

Hi,

a bit of digging around and I think it is a versioning issue with old modules:
https://social.msdn.microsoft.com/Forums/azure/en-US/d8c9a0ae-c70c-4644-aaa3-1ebb98f34cac/error-with-pandas-in-python-script?forum=MachineLearning

anyone got any ideas?
ta,
mike

Hi,
so I went to a really old python forum page and used the code there:
https://www.knime.com/forum/scripting-integrations/python-scripting-output-table

but I wonder why KNIME is calling python where I’m not asking it to?
Is this just a windows feature?

Traceback (most recent call last):
File “C:\KNIME\plugins\org.knime.python2_3.5.0.v201712011355\py\PythonKernel.py”, line 491, in execute
exec(source_code, self._exec_env, self._exec_env)
File “”, line 1, in
ImportError: No module named ‘name_cleaver’

Hi mazzo

I am having an issue with the same code right now and was wondering how you solved it/what code you used to fix the error.

Thanks, Samanta