Linux Installation instructions

The installation of Python and the ROOT libraries consist of three steps:
1) Installing Python
2) Installing ROOT
3) Importing ROOT from Python (setting of environmental variables)

1 Installing Python 2.7:

Python is available in all major linux distributions. If it is not installed already, install it using your favorite package manager (e.g. Software Center in Ubuntu). The package is typically called python or python2.7. Install Python 2.7: sudo apt-get install python Update of Python 2.7 to newest version: sudo apt-get upgrade python

1.1 Testing your python installation

Open a terminal and type:
>> python --version
Python is installed if the output is similar to:
Python 2.7.12

2 Installing ROOT:

With Ubuntu this is very easy (proved doable in less than 2 minutes!). Start by installing ROOT (already compiled), by issuing the following command in the place you want ROOT installed:
>> sudo apt-get install root-system libroot-bindings-python5.34

If that (or something similar for other Linux flavors) doesn't work, or in case you like to compile things yourself, then the recipe is to first download the ROOT source distribution (v5.34) from the ROOT download website onto your Desktop. Next, extract the .tar archive. From the terminal move the folder you extracted to the desired destination of installation (e.g. /usr/local):
>> sudo mv /home/yourname/Desktop/root /usr/local/.
>> cd /usr/local/root
>> ./configure --all
If some Build Prerequisites need to be installed, install them. Once you have installed all of them type again:
>> ./configure --all
>> make

At this point ROOT is installed. In order to set up ROOT for running, type:
>> source ./bin/thisroot.sh
>> root (this command opens root now)
To exit ROOT, type ".q".

In order to avoid setting up ROOT every time you want to use it, it is suggested to add the following line to the end of your file "~/.bashrc": "source /usr/local/root/bin/thisroot.sh".
In this way ROOT can be opened from anywhere just typing ">> root" in the terminal.

3 Importing ROOT from Python:

In order to import the ROOT library in a python environment:
>> export PATH="/usr/local/root/bin:$PATH"
>> export PYTHONPATH="/usr/local/root/lib:$PYTHONPATH"

To test if the ROOT library is successfully imported into Python, try to open Python and import the ROOT library:
>> python
>> import ROOT
If no error appears, all is correct.

Executing a test script

Now that you have a working Python/ROOT setup, you should be able to download and execute the following Python script CalcPrimeNumbers.py, which uses ROOT (if you have trouble downloading the file, try clicking the link with the right mouse button and select "Save As"). Download the script, open a terminal and navigate to the folder where you saved the script. Execute the script with this command:
>> python CalcPrimeNumbers.py
A version of the script with more detailed documentation in the code is available here.
If you don't like to lift your fingers from the keyboard, the following two commands gets you the script and runs it:
>> wget http://www.nbi.dk/~petersen/Teaching/Stat2016/PythonRootIntro/CalcPrimeNumbers.py
>> python CalcPrimeNumbers.py

Writing your own script

To write your own scripts, or edit the downloaded ones you can simply open them in a text editor. New scripts can be written in a new document with the file extention .py at the end of their name.
Most default editors (kwrite, gedit) in Linux distributions include syntax highlighting and many other features and any of them is a good choice. If you are looking for an advanced and easy to use editor, try kate.