Skip to content

GUI-ScientificComputing-Python!

September 4, 2013

So what if you want to create a GUI for your code, and additionally, your code requires complex scientific calculation? This particular set up in a Linux environment might trouble some guys out there. And I’d want you not to waste time setting up, but do it quickly, and so the step-by-step procedure given to you.

Firstly, you must know how to install packages from your respective package manager. If the installations are done in some other order, you could face a hell lot of trouble getting back to the starting position and the most common solutions seems to re-install your OS.  Dependencies! Ohh I tell ya…..So now lets get to business.

Qt is a cross-platform GUI development framework that I used for creating buttons, widgets, text boxes, etc. PyQt are the Python bindings for Qt toolkit. For mathematical functions and plotting, I preferred matplotlib over the others, because of the many example-codes available in its website. Numpy and Scipy are pretty popular python packages for Numerical and Scientific computing. Go step-by-step:-

1. Install python3.2.
2. Download Qt and install it by typical terminal commands.
3. Install python3-sip ; python3-sip-dev.
4. Install python3-pyqt4.qsci ; python3-pyqt4 ; libqscintilla2-dev.
5. Install libpng++-dev ; libjpeg8 ; libjpeg62 ; libjpeg62-dev.
6. Install libfreetype6-dev.
7. Install python3-numpy ; python3-scipy.
8. ipython3 ; ipython3-notebook
9. install matplotlib through source files. (Download it from its website first).

All these are to be installed through your package manager, or terminal command
sudo apt-get install package-name

So now are ready to import them to python code and check if you’ve done everything perfect.

rohit@rohit-SVS13112ENB ~ $ ipython3
Python 3.2.3 (default, Oct 19 2012, 19:53:16)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1.rc2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: exit
rohit@rohit-SVS13112ENB ~ $

Check if your ipython notebook works fine…

rohit@rohit-SVS13112ENB ~ $ ipython3 --pylab
Python 3.2.3 (default, Oct 19 2012, 19:53:16)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1.rc2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Welcome to pylab, a matplotlib-based Python environment [backend: Qt4Agg].
For more information, type 'help(pylab)'.
In [1]: exit
rohit@rohit-SVS13112ENB ~ $

Now its time to import PyQt, numpy, scipy and matplotlib into your python code.

rohit@rohit-SVS13112ENB ~ $ python3
Python 3.2.3 (default, Oct 19 2012, 19:53:16)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4.QtCore
>>> import PyQt4.QtGui
>>> import numpy
>>> import scipy
>>> import matplotlib
>>> exit()
rohit@rohit-SVS13112ENB ~ $

If all these commands go error-free, get a bottle of beer and cheers to python! So basically, sometimes even setting up your system for a combination of packages might make you go crazy. I’d say, play around with your computer, learn to debug, avoid looking for solutions on forums or blogs unless you go like “I wanna kill myself” 😛 Nite!

Advertisements

From → Linux, Project

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: