06/05/2010

Parallel Python Client with matplotlib and pylab trouble

Problem: use OpenSuSE 11.1 as parallel python client with numpy, scipy and matplotlib, which starts automatically at boot time without the need to have anyone logged in.

Solution:
  • install python 2.6, python-matplotlib, python-scipy, python-pylab via YaST - there is a repo called science where you can find all those packages. You might want to use OpenSuSEs software search to find the appropriate repos
  • download the newest parallel python and install it according to the readme file in the tar-file
  • create a new user with YaST (I call it ppython here). I disable the login for security reasons for this user
  • become root, create a text document, copy the following content into it, save it to the folder /etc/init.d/ with the name ppython and make it executable (chmod a+x ppython) - change the dummy IP to your actual IP and the username ppython if you named it differently
    (the startupscript will start the parallel python server at bootup with the user ppython running in the background, listening on the port specified after the -p argument - here 35000 - so that there is no need for anybody to log into the computer).
    #! /bin/sh
    # /etc/init.d/ppython
    #
    ### BEGIN INIT INFO
    # Provides: ppython.py
    # Required-Start: $network $remote_fs
    # Required-Stop: $network $remote_fs
    # Default-Start: 3 5
    # Default-Stop: 0 1 2 6
    # Description: Start the parallel python server
    ### END INIT INFO

    # Some things that run always
    # touch /var/lock/blah

    # Carry out specific functions when asked to by the system
    case "$1" in
    start)
    echo "Starting parallel python server"
    echo ""
    su ppython -c "/usr/local/bin/ppserver.py -p 35000 -i 123.45.167.34 &"
    ;;
    stop)
    echo "Stopping parallel python server"
    echo ""
    killall python
    killall ppserver.py
    ;;
    *)
    echo "Usage: /etc/init.d/ppython {start|stop}"
    exit 1
    ;;
    esac

    exit 0

    I know, the script is extremly dirty and could be improved a lot, but it works.
  • Start the Module System --> RunLevel editor in YaST, look for ppython, switch to expert mode, check runlevel 3 and 5 and say ok to the changes.
  • Open the port ppserver is listening on for TCP und UDP in the Firewall using the Firewall Module in YaST.
After a reboot the process ppserver.py shows up with two additional python processes run by the user ppython. So far so good. But trying to use the client did not work: all jobs were handed back with a lot of error codes refering to GTK problems.
The solution is to change the backend to TkAgg as follows:
  • install the package python-tk
  • look for the file matplotlibrc - it normally resides in /usr/lib/python2.6/site-packages/matplotlib/mpl-data/, open it as root and look for the "backend =" line - there change from GTKAgg to TkAgg
Now you should be able to use the parallel python client.

No comments: