Hi everybody,
I have python script which runs in Spyder with no errors. But when I run it in KNIME through [Python Script 1->1] node, I get confusing errors.
In fact ‘ta’ library generates financial indicators for stock prices and I need to integrate it in KNIME.
this is the python code:
import ta
import pandas as pd
df = pd.read_csv(“stock.txt”, sep = “,”)
ta.add_all_ta_features(df, “Open”,“High”, “Low”, “Close”, “Vol”, False, “”)
in Knime, I have inserted the below script in Python Script node:
import ta
output_table = input_table.copy()
ta.add_all_ta_features(output_table, “Open”,“High”, “Low”, “Close”, “Vol”, False, “”)
I appreciate any help
ScottF
March 17, 2020, 6:09pm
2
Hi @jalilsh -
What errors are you seeing? Can you provide those, or a bit of the relevant log?
Also, as a quick check, can you make sure that that output of your code is a pandas dataframe? This is required for the node to execute properly.
3 Likes
I set up this example with data from the website of the package ta . Maybe you take a look.
3 Likes
Hi @mlauber71 ,
thanks for your reply. This is the error I get with my code
My workflow and the text data is as below:Add Indicators.knwf (7.7 KB) Test.txt (180.6 KB)
It is interesting. I get similar error with the workflow you provided. Maybe there is something wrong with Python environment settings
I was able to run your workflow without problems. I attached it including the results.
Add Indicators2.knwf (2.3 MB)
I think you would have to check your Python environment.
Some short steps and hints:
A few more general remarks:
with Python and KNIME it is all about compatibility and consistency of the packages. That is where Anaconda tries to help
you should not update individual packages but let Anaconda manage that
concerning Tensorflow and Keras note which versions are supported by the various KNIME nodes (typically that is not the most recent version)
these versions must be compatible with your Python version (it might be that it is to large)
I am working on a text about KNIME and Pyt…
Bot that much actually. It boils down to this:
use Anaconda and be aware of different channels
mostly stick to one channel like the default “Anaconda”
be aware of channel priorities (which is not straightforward), stick to you original channel
let Anaconda do most of the management of dependencies
use “conda update anaconda” and “conda update conda”
if a package is not available you might use pip
if you Python installation becomes corrupt delete the whole thing and start over again
I have not…
The official guide:
https://docs.knime.com/latest/python_installation_guide/index.html
3 Likes
thanks a lot.
in fact it was a problem with Python environment. the required library was not accessible to KNIME at first.
I tried to run the scripting with all the columns and it didn’t work, then I filtered the columns you wanted and then I created a new column to test and it worked as the image shows.
1 Like
system
Closed
June 2, 2023, 9:28pm
8
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.