I upgraded to KNIME 4.7 and now I get error when running the Python script node.
See added screenshots . . .
Are there any bugs in 4.7 regarding this issue?
Hopefyully someone can help.
THNX in advance
I upgraded to KNIME 4.7 and now I get error when running the Python script node.
See added screenshots . . .
Are there any bugs in 4.7 regarding this issue?
Hopefyully someone can help.
THNX in advance
Hi @sanderlenselink,
thanks for reporting. Could you in this scripting node try to reset workspace, then execute the following selected lines
import sys
print(sys.path)
and post the result?
Additionally, could you get the knime log and attach the errors from there and their surrounding as a txt file here?
Thanks!
Steffen
Hi Steffen,
after Resetting the Workspace I get a 2nd message âAn exception occured while running the Python kernel. See log for details.â
The commands âimport sysâ and âprint(sys.path)â donât work because of the beforementioned message (I suppose)
The log-file stays empty (so maybe it isnât an error . . . but something else???)
Hopefully this helps you . . . otherwise let me know what I can do
-Sander
= = = =
Hi,
with empty log file, do you mean the error log shown in your screenshot or do you mean the log file I requested with a link? Please share that knime log file, which can be obtained via
View --> Open KNIME log
.
Best regards
Steffen
Hi Steffen,
both . . . via View > Error log and the screenshot. Both keep empty.
And in fact thatâs strange because the system responses with ERROR but the logfile keeps empty
An idea to discuss the problem via Teamviewer?
-Sander
Hi,
I specifically asked not for the error log, but for the KNIME log. It should look like this:
is that empty as well?
Regards
Steffen
Hi Steffen,
sorry, I was focused at Error-log . . . attached the requested log-file
mea culpa
-Sander
knime._log_20230327_sanderlenselink.txt (6.0 KB)
Hi,
thanks! We think that is because in your environment py39_knime_yfinance
you have some module knime
installed. Is it the following one: GitHub - knime/knimepy ?
Could you remove it (conda remove -n py39_knime_yfinance knime
) or create a new environment with your specific packages and try the new environment?
Does that work?
Best regards
Steffen
Hi Steffen,
I keep on struggling . . . if I switch to the base environment it runs fine.
However, if I create a new enviroment . . . I get some errors (screenshot). I tried this not only for python 3.9 but also 3.8 and 3.7. The result is the same.
If I dive into the environment it appears that âsocket.pyâ cannot be found
Maybe you know the reasons for this?
Regards
-Sander
= = = =
= = = = =
Hi Sander,
Iâm sorry that this is so complicated right now. I have not seen this error before, could you copy paste the whole error mesage from the second screenshot? I wonder how it originates.
Meanwhile, could you try to generate a conda environment via terminal / anaconda prompt? See this section of the guide for how to do that. Are you also using other packages then the preinstalled ones? Because then, this is the recommended way. If you donât use other packages, you could use the bundled version (in the screenshot, in the top of the Python
preferences, click on the radio button Bundled
).
Let me know the answers and if anything works. We will figure this out.
Best regards
Steffen
Hi,
I created a new a new environment via the terminal with this command:
This process runs smoothly. If I switch to this new environment and e.g. run âpip listâ I get the same message I sent you some minutes ago.
If I check in KNIME > Preferences > Python . . . the result is the same
= = = =
Yes I work with additional libraries such as yfinance and yahooquery. These are loaded in the base-environment and work fine.
BTW I didnât load yfinance / yahooquery in py39_knime_steffen
This helps you?
-Sander
Hi,
thanks for the error messages. According to stackoverflow, there might be issues because of mixing Python2 and Python3.
I, personally, would try a clean reinstall of anaconda3 and delete everything you have at C:\Users\sande\anaconda3
before reinstalling it.
It especially seems odd that your environment refers to C:\Users\sande'anaconda3\envs\lib
. Not sure whether there should be such a folder. If you donât want to reinstall anaconda, could you try deleting that folder?
As a third option, which you could try additionally to any of the first two, you could try what the thread opener from the stackoverflow did:
EDIT: It seems that when I uninstalled Python, I neglected to delete the C:\Python27 folder. I uninstalled again, deleted the folder, then reinstalled and it works now. Thanks for the help.
Let me know what you try and what the results are.
Best regards
Steffen
Hi Steffen,
I followed your (personal) suggestion by re-install anaconda and . . . . we succeeded. Creating a new environment within KNIME runs smoothly. I removed also the old Python 2 version
Iâm very happy and thnx for your extensive help
Altough the base-environment generates som errors (screenshot) but I suppose thatâs because itâs build on Python 3.10.
Hi,
no, the base
environment is installed by your environment manager (anaconda) by default. It does not contain the packages we need for the Python Script nodes. These required packages are py4j
and pyarrow
. That is why we offer creating it via the New environment...
button or the preferred way via commandline conda create -n <env_name> knime-python-script=4.7 and so on and so forth
. These two ways ensure that the necessary packages are installed in an environment. You could also install the knime-python-scripting
package in your base
environment, but I suggest just leaving that environment as is and use dedicated environments for your specific purposes.
Iâm glad it worked!
Best regards
Steffen
@sanderlenselink one idea could be to read my article about KNIME and conda environments. My suggestion would be to use Miniforge and start with a minimal setup:
I had the same problem and solved it by:
It is actually a bit confusing. One is tempted to install this library, although it is not explained in the KNIME Python Integration Guide.
Where is this knime.scripting.io
library is coming from?
Hi,
removing the knime package
which package? This one: GitHub - knime/knimepy ?
Just to understand it better: why is one tempted to install that library?
knime.scripting.io
is shipped with the Python integration beginning with KNIME Analytics Platform 4.7
Best regards
Steffen
Hi Markus,
thnx for your tip to and writing the article about âSetting up and managing Conda environmentsâ. Very , very helpful.
In general it is clear what a yaml file does: a backup and exchange file of your librairies. Reading was easy but implementing a bit more challenging. But in the end I succeed
If you are interested, below a few little suggestions for additional explanation . . .
As said . . for me your article is very useful and well worth the time investment.
I can recommend it to everyone.
The above points are just small additions that may help newbies (like me) regarding conda / yaml / environments.
@sanderlenselink thank you for the feedback and the hints. I tried to remark on most questions someone might have and indeed a lot of remarks are written from a Mac perspective. To a certain degree mastering Python and conda will involve your own experiences and learnings I think.
I had hoped this line and the path would have at least implied that since I often find guides that would just assume everything is in some root directory so I try to hint at individual settings without overloading the code:
âYou might want to save your YAML file somewhere on your machine where you keep important configurations.â
My learning was that I would need the from history setting in order to get all the packages from the (well) installation history. The point here is you would want just the major packages and the dependencies to sort the out themselves (via conda) but right now there is no mechanism to do this. So you either keep a âcleanâ YAML file and use that to add packages or you use the more detailed version. I tend to write limited YAML files with just the additional packages I need. Upside: you have a better overview about the packages. Downside: you have to maybe manage several environments.
That very much depends on your needs. If the bundled version has all the packages you need that might be the one to choose. But you can also mix that and have Python nodes with the bundled version and some which would have additional packages. KNIME is adding packages but of course with an âembeddedâ version you have to make sure everything would work on all operating systems and you would not pack too much dependencies. But with the bundled version you already can do a lot.
I am not aware of such a video that is specific to Python and KNIME, I think other videos about conda might exist. Videos for me often mean and additional effort and you cannot easily edit or copy paste the code. But might be an idea. And I think there are videos about KNIME and Python out there.
So again: thank you for your hints and comments. I will keep in mind to further explicitly state the purpose of some of the things that I do