Building Python from Source
The following are notes for building and installing tcl/tk/python 2.7.6 from source into a custom directory.
The following was done on Cent OS 6.5 and uses bash syntax (version > 4). It also assumess a shell variable, LOCAL
, is defined where you keep your files in your home directory. Mine is defined in my .bashrc
as export LOCAL=$HOME/local
. Don’t forget that when you update your .bashrc
file, you must restart bash or run source ~/.bashrc
to make changes available.
Let’s get started.
We should build and install Tcl/Tk before python. This library is especially important if you plan to install matplotlib - a great plotting library for python. You can skip this step if you don’t plan on installing matplotlib. In fact, you can still install matplotlib without Tcl/Tk, and you’ll have all the functionality to save figures to file, but no X11 graphical interactivity. There’s other X11 backends for matplotlib such as pygtk
. However, pygtk
has a laundry list of dependencies that are a pain to install.
First, let’s do Tcl:
And Tk next:
OK that was easy. Now let’s install python. You should have shell variable, PYPATH
, defined that specifies where python will be installed. For instance, in my .bashrc
, I have: export PYPATH=$LOCAL/lib/python/2.7.6
.
Update (or define if they aren’t already) the following in your .bashrc
:
Now we need to create some symlinks:
Now check
Finally, you should install pip. Pip is a package manager for python libraries that, when possible, makes installing and book-keeping python extensions a breeze. Install as follows:
Great. Now you can install some other great packages easily:
Numpy and SciPy are two important libraries for mathematical / scientific computing. You should build them from source rather than installing using pip so that way you can point to your system’s LAPACK/BLAS/ATLAS libraries. I won’t talk about doing that here.