Installing a new library in Python

Hii,
Please tell me all the ways in which i can intall a new python library in knime.
Also tell me how to check which libraries are alredy installed

Hi @06mickey
Did you follow the instructions on https://docs.knime.com/2019-06/python_installation_guide/index.html#setup_python_integration? If so you maintain your Python environment in conda. There you can check which packages are installed.

2 Likes

the guide only tells how to setup a new conda env. , please share details on how can we install a library which is not already installed in our python, in knime.

You could install additional Python packages via Anacona command “conda install”

Like discussed here for deep learning environments.

With Python it is all about package dependencies and compatibility which Anaconda is meant to handle.

You should use one channel as your priority channel as discussed in the link. To read more about package management you could look here

https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html

You could also use the more graphical Anaconda Navigator but I would recommend the above approach.

4 Likes

can’t we use pip install command for package installation?

If for example a package is not in a channel you could use pip but you might have to deal with compatibility issues.

Thanks a lot for quick reply

I would set on a default channel and if a package is there use that. If you install something via pip you could run

conda update conda

Afterwards to try and prevent compatibility issues. But there is no guarantee. You might have to reinstall Python or use several conda environments.

You can use pip inside a conda environment. But as mlauber71 said, depending on the package and the operating system you use, it might work or not work.

condas biggest advanatge is mostly on windows for packages that have binary and/or complex dependencies. On linux you usually have a compiler tool chain installed and can also install packages from pip that need compilation. So on linux (and mac) pip will most likely always work. And windows you could run into problems.

For pure python packages, it will always work. However conda can’t fully manage packages installed via pip and you can still run into issues with dependencies.

Off-topic:
Be aware that numpy etc. installed via conda is compiled with intel mkl library. This library leads to poor performance on AMD Zen CPUs (Ryzen, Threadripper, Epyc) (well in fact all AMD CPUs are affected but if you are running anything older than these, performance doesn’t seem to matter to you anyway :slight_smile:).
To fix the performance problem, one can set and environment variable

MKL_DEBUG_CPU_TYPE=5

which will “restore” performance. I’m mention this because if you use linux with the default python and pip, numpy and co. are compiled against openblas which by default has good performance on AMD CPU.

3 Likes

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