Skip to content

Python server for knime

Martin Stöter edited this page Jun 8, 2015 · 15 revisions

The Python installation allows other software to execute Python code, for example to produce plots. In particular there is KNIME that makes extensive use of Python plots.
There are two options:

  1. install Python on local computer (local Python installation)
  2. install Python on another computer in the network (remote Python server)

Table of Contents

How to setup a local Python installation

  • we highly recommend to use the Anaconda Python distribution
  • download Anaconda and install it on your computer
  • start the Anaconda Launcher and make sure you have a Python 2.x version installed
  • check by running in the command line (Mac: Terminal; Windows: Command Prompt):
python --version
  • set up the connection to KNIME by following instructions below.
  • alternatively, install Python (2.x) and the packages listed below.

How to setup a remote Python-Server?

  • install Anaconda (or Python 2.x) on a computer accessible in your network
  • if necessary (Python 2.x) install packages listed below.

Setting up the remote Python-Server in Mac OSX or Linux

  • download the latest stable mpicbg-python binaries from here and unpack the zip-file at the location of your choice.
  • use any editor to change your chosen path to the pyserver folder in the pyserver.sh.
  • use the command line to start the python server:
./pyserver.sh

The port number can be passed as an option to the script.

./pyserver.sh 1199

Setting up the remote Python-Server in Windows

It is not supported for now to setup a Python-server under Windows. Hopefully this will come soon in the future…

How to set up connection to KNIME

Go to KNIME > Preferences > KNIME > Python Scripting, to tell KNIME who to talk to.

 host: localhost (or whatever IP or DNS of computer running the remote Python-server)
 port: 1198
  • to check the connection drag and drop a Python Snippet node and connect to some data
  • just execute (no configuration needed) and if successful the Python-server connection is working

Install packages required for Python templates in Knime

The Anaconda Python distribution comes already with a number of useful and necessary packages, like NumPy, SciPy, Matplotlib, … We recommend using the Anaconda distribution because you do not have to take care about installing necessary packages.
However one could also use any Python 2.x installation. To prepare your Python installation for all the tds-templates, you need to install the additional packages listed below.
These are the links to the templates and might need to be entered into the KNIME preferences: Python-plot:

https://raw.githubusercontent.com/knime-mpicbg/scripting-templates/master/knime-scripting-templates/Python/figure-templates.txt
Python-snippet:
https://raw.githubusercontent.com/knime-mpicbg/scripting-templates/master/knime-scripting-templates/Python/snippet-templates.txt

To use all templates install these packages in your Python installation.

Install packages for Windows Anaconda

The plot 'Venn Diagramm' depends on the external package 'matplotlib-venn'. These instructions should help you to install this package under Windows:

  • run Anaconda Command Prompt under administrator rights (maybe it works also without admin rights!?)
  • on command prompt change directory to anaconda program, eg: (may this is also not needed!?)
 cd "C:\Program Files\Anaconda\" 
  • install package by running:
 easy_install matplotlib_venn 
  • restart Anaconda or iPython and you should be able to import package using: import matplotlib_venn
  • if that works that packages should be installed and the Venn plot-template should run as well