Python Nodes - pip install of module possible?

Is there any way to get the Python nodes to do check for a module and install if necessary?
Somewhat like in Jupyter the !pip install ?
I am using a module that I wrote and is on Git, on cmd line I would thus use e.g.
python -m pip install git+https://repository
(Works fine with multiple anaconda environments)
For myself its not a big deal, but for colleagues who know nothing about Python and just want a functioning node it would be helpful. Maybe even for sharing here.

Hi @docminus2 –

It does not perform exactly this “pip install this one thing” task but it seems like the Conda Environment Propagation node is designed to help provide all dependencies for your “colleagues who know nothing about Python and just want a functioning [Python] node”.

Davin

1 Like

Hi,
thanks for that tip. That is almost what I am thinking of.
Unfortunately it seems to have two (three) drawbacks though -
a) only for Knime 4.3.x (not a “disaster” though)
b) only works for official pip packages, not like the unofficial ones I described

(and I guess conda resp. conda-forge isn’t possible either?)

Hi @docminus2 –

On those topics:

a) Yes, that node is not available in older versions of KNIME.

b) Two parts here:
b1) conda-forge and any other conda channel works just fine – the Conda Environment Propagation node should replicate packages based upon the channel they came from originally.
b2) Once a conda env is created and you pip install from a git repo (rather than from PyPI) into that conda env, conda is aware of what packages were installed via pip (and how). I do not have an appropriate conda env immediately available to test this, but I would expect conda to be fully capable of recreating that conda env with the pip-install-via-git package and all other pip-installed packages. Did you experience otherwise?

Davin

hi again, thanks once more.
regarding conda, my bad, I must have done something wrong at first, it does indeed install as you write (otherwise the name of “Conda propagation” wouldn’t make much sense now, would it? :smiley: )
I did get a " Execute failed: Pip failed" though for my package. Then I restarted Knime and rerun it, no error message came up. But when I want to import the module I get a “ModuleNotFoundError”. Could be my setup.py? This is my very first Python package.
Here is the remote repo I am trying to include:

Manually I would install it as written above (or on the git readme):
python -m pip install git+https://github.com/DocMinus/chem-rdf-fixer.git

It requires Pandas and RDKit. For the latter I rely on manual install, haven’t figured out how to add a conda-forge package to a pip setup. Eventually I think I will do a conda-forge package out of this.

Any help is welcome. Once this works I was anyway thinking of sharing the resulting Knime WF here.
(it’s basically to replace the Erlwood Reaction Reader which bugs out in V4.2 and doesn’t even exist in 4.3).

1 Like

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