# Using PyROOT in Ubuntu 14.04

**URL:** <https://root-forum.cern.ch/t/using-pyroot-in-ubuntu-14-04/20567>\
**Category:** ROOT\
**Created:** [February 7, 2016, 3:49pm UTC](https://root-forum.cern.ch/t/using-pyroot-in-ubuntu-14-04/20567 "2016-02-07T15:49:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![scheong](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@scheong](https://root-forum.cern.ch/u/scheong)\
**Post date:** [February 7, 2016, 3:49pm UTC](https://root-forum.cern.ch/t/using-pyroot-in-ubuntu-14-04/20567/1 "2016-02-07T15:49:41Z")

</div>

From my Ubuntu terminal, I can run both python (2.7.6, default for Ubuntu 14.04) and root (6.06/00) simply by typing “python” and “root” without any issues.

However, I cannot import root from my python–whether it be in the terminal or any other python files that try to import root. I get:

> > > import root  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > ImportError: No module named root

I tried following [wlav.web.cern.ch/wlav/pyroot/installation.html](http://wlav.web.cern.ch/wlav/pyroot/installation.html), but did not really help. On my Ubuntu, all the environment variables PYTHONPATH, ROOTSYS, PYTHONDIR, and LD\_LIBRARY\_PATH are empty. I tried setting them to the relevant directories, but I still could not import root from python. My path variable, by default, is:  
scheong@scheong-Inspiron-7347:~$ echo $PATH  
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Should ROOTSYS and PYTHONDIR variables be where my python and root are?

Do you have any specific guides to properly set up the environment variables? Or, is there any easier way to import root from python?

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [February 7, 2016, 5:41pm UTC](https://root-forum.cern.ch/t/using-pyroot-in-ubuntu-14-04/20567/2 "2016-02-07T17:41:52Z")

</div>

Note: it should be “import ROOT”.  
See: [Import ROOT error](https://root-forum.cern.ch/t/import-root-error/14636/2)

---

<div class="post-metadata">

**Author:** ![scheong](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@scheong](https://root-forum.cern.ch/u/scheong)\
**Post date:** [February 7, 2016, 9:06pm UTC](https://root-forum.cern.ch/t/using-pyroot-in-ubuntu-14-04/20567/3 "2016-02-07T21:06:13Z")

</div>

I’ve already tried import ROOT, same issue.

---

<div class="post-metadata">

**Author:** ![scheong](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@scheong](https://root-forum.cern.ch/u/scheong)\
**Post date:** [February 7, 2016, 9:10pm UTC](https://root-forum.cern.ch/t/using-pyroot-in-ubuntu-14-04/20567/4 "2016-02-07T21:10:33Z")

</div>

[quote=“Pepe Le Pew”]Note: it should be “import ROOT”.  
See: [https://root-forum.cern.ch/t/import-root-error/14636/2[/quote]](https://root-forum.cern.ch/t/import-root-error/14636/2%5B/quote%5D)

I tried checking the root config. It does have Python in the features, and I do get yes when I try root-config --has-python.

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [February 7, 2016, 9:17pm UTC](https://root-forum.cern.ch/t/using-pyroot-in-ubuntu-14-04/20567/5 "2016-02-07T21:17:38Z")

</div>

In order to set all relevant system variables, execute for [bdkz][a]sh:  
. /Where/Your/Root/Is/bin/thisroot.sh  
or for [t]csh:  
source /Where/Your/Root/Is/bin/thisroot.csh

---

<div class="post-metadata">

**Author:** ![scheong](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@scheong](https://root-forum.cern.ch/u/scheong)\
**Post date:** [February 8, 2016, 10:28pm UTC](https://root-forum.cern.ch/t/using-pyroot-in-ubuntu-14-04/20567/6 "2016-02-08T22:28:22Z")

</div>

[quote=“Pepe Le Pew”]In order to set all relevant system variables, execute for [bdkz][a]sh:  
. /Where/Your/Root/Is/bin/thisroot.sh  
or for [t]csh:  
source /Where/Your/Root/Is/bin/thisroot.csh[/quote]

source /path/to/root/bin/thisroot.sh solved the problem; it left me with a question, however.

I ran the exact same lines manually, trying to setup the environment variables as required, and I was still having issues. [thisroot.sh](http://thisroot.sh) file seems to do nothing more than that: setting up the environment variables.

Is there any difference between manually editing the environment variables using export ROOTSYS= blah blah and whatnot, and running source [thisroot.sh](http://thisroot.sh)?

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [February 8, 2016, 10:44pm UTC](https://root-forum.cern.ch/t/using-pyroot-in-ubuntu-14-04/20567/7 "2016-02-08T22:44:10Z")

</div>

No difference whatsoever.

---

<div class="post-metadata">

**Author:** ![scheong](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@scheong](https://root-forum.cern.ch/u/scheong)\
**Post date:** [February 8, 2016, 11:08pm UTC](https://root-forum.cern.ch/t/using-pyroot-in-ubuntu-14-04/20567/8 "2016-02-08T23:08:13Z")

</div>

My professor said the same thing.

Either some weird coincidence of other bugs/errors didn’t make it work when I tried it manually, or I guess I typed in the wrong directories.

Anyways, I think everything is good (at least for now).

Thanks!
