Pyroot environment variables with Scientific Linux 7.2

Hi there,

I’m currently trying to get Pyroot (root_v6.06.02.Linux-slc6-x86_64-gcc4.8) on a Scientific Linux 7.2 machine working. The python version is the preinstalled 2.7.5.
ROOT itself is working fine in a terminal, but the module doesn"t get found in python (typical ‘no module named ROOT’ error).

I’ve tried 2 different things:

  1. use ‘. /root/bin/thisroot.sh’ , however nothing happens if I run it, no environment variables are set.
  2. Try it with
    export PATH=$ROOTSYS/bin:$PYTHONDIR/bin:$PATH
    export LD_LIBRARY_PATH=$ROOTSYS/lib:$PYTHONDIR/lib:$LD_LIBRARY_PATH
    export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH

However I’m not sure what the PYTHONDIR variable should be, as I can’t find a python folder with a ‘bin’ folder inside of it.

This is the result of sys.path: [’/home/mmoser/PycharmProjects/General’, ‘/usr/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg’, ‘/home/mmoser/PycharmProjects/General’, ‘/usr/lib64/python27.zip’, ‘/usr/lib64/python2.7’, ‘/usr/lib64/python2.7/plat-linux2’, ‘/usr/lib64/python2.7/lib-tk’, ‘/usr/lib64/python2.7/lib-old’, ‘/usr/lib64/python2.7/lib-dynload’, ‘/usr/lib64/python2.7/site-packages’, ‘/usr/lib64/python2.7/site-packages/gtk-2.0’, ‘/usr/lib/python2.7/site-packages’]
The python interpreter (executable, not folder) seems to be in ‘/usr/bin/python2.7’.

So what directory should I use for PYTHONPATH or is there a way to get thisroot to work?

Thanks a lot! :slight_smile:

Edit:
Actually 1) with thisroot works if you execute it just before opening python. Do i need to add the thisroot command somewhere such that for every terminal (and for my pycharm editor terminal) ‘source /root/bin/thisroot.sh’ is executed automatically? I use a bash shell.
In Windows you only have to do it one time, that’s why I’m asking.

Hi,

This proves that your installation is sound. Now, to avoid running the command, try adding “path/to/root/lib” to the PYTHONPATH.

Cheers,
Danilo

Thanks!
I tried adding the environment variables manually to the .bash_profile and the .profile and at least the import ROOT statement now works.
this is my new .bash_profile:

[code]# .bash_profile

Get the aliases and functions

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/texlive/2015/bin/x86_64-linux:/home/mmoser/Documents/Programming/root/bin
PYTHONPATH=/home/mmoser/Documents/Programming/root/lib
LD_LIBRARY_PATH=/home/mmoser/Documents/Programming/root/lib

export LD_LIBRARY_PATH
export PYTHONPATH
export PATH[/code]

So importing works now everytime, but if I e.g. create a Canvas

i get errors:

[code]cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
Error in TInterpreter::TCling::AutoLoad: failure loading library libASImage.so for TASImage
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
Error in TInterpreter::TCling::AutoLoad: failure loading library libASImage.so for TASImage
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
Error in TGHScrollBar::TGHScrollBar: arrow_.xpm not found
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
Error in TInterpreter::TCling::AutoLoad: failure loading library libASImage.so for TASImage
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
Error in TInterpreter::TCling::AutoLoad: failure loading library libASImage.so for TASImage
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
Error in TGVScrollBar::TGVScrollBar: arrow_
.xpm not found
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory
Error in TInterpreter::TCling::AutoLoad: failure loading library libASImage.so for TASImage
cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

Thread 2 (Thread 0x7fbfe9436700 (LWP 5599)):
#0 0x00007fbffed9b790 in sem_wait () from /lib64/libpthread.so.0
#1 0x00007fbfff0b67b5 in PyThread_acquire_lock () from /lib64/libpython2.7.so.1.0
#2 0x00007fbfff0858a6 in PyEval_RestoreThread () from /lib64/libpython2.7.so.1.0
#3 0x00007fbfe9439086 in time_sleep () from /usr/lib64/python2.7/lib-dynload/timemodule.so
#4 0x00007fbfff08aaa4 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#5 0x00007fbfff08c0bd in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#6 0x00007fbfff01905d in function_call () from /lib64/libpython2.7.so.1.0
#7 0x00007fbffeff40b3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#8 0x00007fbfff0872f7 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#9 0x00007fbfff08a860 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#10 0x00007fbfff08a860 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#11 0x00007fbfff08c0bd in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#12 0x00007fbfff018f68 in function_call () from /lib64/libpython2.7.so.1.0
#13 0x00007fbffeff40b3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#14 0x00007fbfff0030a5 in instancemethod_call () from /lib64/libpython2.7.so.1.0
#15 0x00007fbffeff40b3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#16 0x00007fbfff085f07 in PyEval_CallObjectWithKeywords () from /lib64/libpython2.7.so.1.0
#17 0x00007fbfff0ba842 in t_bootstrap () from /lib64/libpython2.7.so.1.0
#18 0x00007fbffed95dc5 in start_thread () from /lib64/libpthread.so.0
#19 0x00007fbffe3ba28d in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7fbfff578740 (LWP 5582)):
#0 0x00007fbffe3810f9 in waitpid () from /lib64/libc.so.6
#1 0x00007fbffe306092 in do_system () from /lib64/libc.so.6
#2 0x00007fbffe306441 in system () from /lib64/libc.so.6
#3 0x00007fbff758e0cf in TUnixSystem::StackTrace() () from /home/mmoser/Documents/Programming/root/lib/libCore.so
#4 0x00007fbff758fc4c in TUnixSystem::DispatchSignals(ESignals) () from /home/mmoser/Documents/Programming/root/lib/libCore.so
#5
#6 0x00007fbfe2362ffe in TGHScrollBar::SetPosition(int) () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#7 0x00007fbfe233e8f8 in TGCanvas::Layout() () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#8 0x00007fbfe2305cd4 in TGCompositeFrame::MapSubwindows() () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#9 0x00007fbfe2305cd4 in TGCompositeFrame::MapSubwindows() () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#10 0x00007fbfe239c455 in TRootCanvas::CreateCanvas(char const*) () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#11 0x00007fbfe239f7a1 in TRootCanvas::TRootCanvas(TCanvas*, char const*, unsigned int, unsigned int) () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#12 0x00007fbfe234d8fb in TRootGuiFactory::CreateCanvasImp(TCanvas*, char const*, unsigned int, unsigned int) () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#13 0x00007fbfe87cbedb in TCanvas::Constructor(char const*, char const*, int, int) () from /home/mmoser/Documents/Programming/root/lib/libGpad.so
#14 0x00007fbfe87ccdec in TCanvas::TCanvas(char const*, char const*, int, int) () from /home/mmoser/Documents/Programming/root/lib/libGpad.so
#15 0x00007fbfff4f308e in ?? ()
#16 0x00007ffe457f0a10 in ?? ()
#17 0x00007fbff16c6a94 in TClingCallFunc::IFacePtr() () from /home/mmoser/Documents/Programming/root/lib/libCling.so
#18 0x000000000000006c in ?? ()
#19 0x00007ffe457f050f in ?? ()
#20 0x00007fbff793a061 in FastCall(long, void*, void*, void*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#21 0x00007fbff793ad4c in Cppyy::CallConstructor(long, long, void*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#22 0x00007fbff7963a63 in PyROOT::TConstructorExecutor::Execute(long, void*, PyROOT::TCallContext*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#23 0x00007fbff7936c69 in PyROOT::TMethodHolder::CallSafe(void*, long, PyROOT::TCallContext*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#24 0x00007fbff7935509 in PyROOT::TMethodHolder::Execute(void*, long, PyROOT::TCallContext*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#25 0x00007fbff795a780 in PyROOT::TConstructorHolder::Call(PyROOT::ObjectProxy*&, _object*, _object*, PyROOT::TCallContext*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#26 0x00007fbff794a9c0 in PyROOT::(anonymous namespace)::mp_call(PyROOT::MethodProxy*, _object*, _object*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#27 0x00007fbffeff40b3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#28 0x00007fbfff04b057 in slot_tp_init () from /lib64/libpython2.7.so.1.0
#29 0x00007fbfff049d6f in type_call () from /lib64/libpython2.7.so.1.0
#30 0x00007fbffeff40b3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#31 0x00007fbfff08825c in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#32 0x00007fbfff08c0bd in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#33 0x00007fbfff08c1c2 in PyEval_EvalCode () from /lib64/libpython2.7.so.1.0
#34 0x00007fbfff0a55ff in run_mod () from /lib64/libpython2.7.so.1.0
#35 0x00007fbfff0a67be in PyRun_FileExFlags () from /lib64/libpython2.7.so.1.0
#36 0x00007fbfff0a7a49 in PyRun_SimpleFileExFlags () from /lib64/libpython2.7.so.1.0
#37 0x00007fbfff0b8b9f in Py_Main () from /lib64/libpython2.7.so.1.0
#38 0x00007fbffe2e5b15 in __libc_start_main () from /lib64/libc.so.6
#39 0x0000000000400721 in _start ()

The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.

#6 0x00007fbfe2362ffe in TGHScrollBar::SetPosition(int) () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#7 0x00007fbfe233e8f8 in TGCanvas::Layout() () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#8 0x00007fbfe2305cd4 in TGCompositeFrame::MapSubwindows() () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#9 0x00007fbfe2305cd4 in TGCompositeFrame::MapSubwindows() () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#10 0x00007fbfe239c455 in TRootCanvas::CreateCanvas(char const*) () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#11 0x00007fbfe239f7a1 in TRootCanvas::TRootCanvas(TCanvas*, char const*, unsigned int, unsigned int) () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#12 0x00007fbfe234d8fb in TRootGuiFactory::CreateCanvasImp(TCanvas*, char const*, unsigned int, unsigned int) () from /home/mmoser/Documents/Programming/root/lib/libGui.so
#13 0x00007fbfe87cbedb in TCanvas::Constructor(char const*, char const*, int, int) () from /home/mmoser/Documents/Programming/root/lib/libGpad.so
#14 0x00007fbfe87ccdec in TCanvas::TCanvas(char const*, char const*, int, int) () from /home/mmoser/Documents/Programming/root/lib/libGpad.so
#15 0x00007fbfff4f308e in ?? ()
#16 0x00007ffe457f0a10 in ?? ()
#17 0x00007fbff16c6a94 in TClingCallFunc::IFacePtr() () from /home/mmoser/Documents/Programming/root/lib/libCling.so
#18 0x000000000000006c in ?? ()
#19 0x00007ffe457f050f in ?? ()
#20 0x00007fbff793a061 in FastCall(long, void*, void*, void*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#21 0x00007fbff793ad4c in Cppyy::CallConstructor(long, long, void*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#22 0x00007fbff7963a63 in PyROOT::TConstructorExecutor::Execute(long, void*, PyROOT::TCallContext*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#23 0x00007fbff7936c69 in PyROOT::TMethodHolder::CallSafe(void*, long, PyROOT::TCallContext*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#24 0x00007fbff7935509 in PyROOT::TMethodHolder::Execute(void*, long, PyROOT::TCallContext*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#25 0x00007fbff795a780 in PyROOT::TConstructorHolder::Call(PyROOT::ObjectProxy*&, _object*, _object*, PyROOT::TCallContext*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#26 0x00007fbff794a9c0 in PyROOT::(anonymous namespace)::mp_call(PyROOT::MethodProxy*, _object*, _object*) () from /home/mmoser/Documents/Programming/root/lib/libPyROOT.so
#27 0x00007fbffeff40b3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#28 0x00007fbfff04b057 in slot_tp_init () from /lib64/libpython2.7.so.1.0
#29 0x00007fbfff049d6f in type_call () from /lib64/libpython2.7.so.1.0
#30 0x00007fbffeff40b3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#31 0x00007fbfff08825c in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#32 0x00007fbfff08c0bd in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#33 0x00007fbfff08c1c2 in PyEval_EvalCode () from /lib64/libpython2.7.so.1.0
#34 0x00007fbfff0a55ff in run_mod () from /lib64/libpython2.7.so.1.0
#35 0x00007fbfff0a67be in PyRun_FileExFlags () from /lib64/libpython2.7.so.1.0
#36 0x00007fbfff0a7a49 in PyRun_SimpleFileExFlags () from /lib64/libpython2.7.so.1.0
#37 0x00007fbfff0b8b9f in Py_Main () from /lib64/libpython2.7.so.1.0
#38 0x00007fbffe2e5b15 in __libc_start_main () from /lib64/libc.so.6
#39 0x0000000000400721 in _start ()

Traceback (most recent call last):
File “/home/mmoser/PycharmProjects/General/TestSetup.py”, line 6, in
canvas = ROOT.TCanvas(‘w’,‘r’,600,900)
TypeError: none of the 5 overloaded methods succeeded. Full details:
TCanvas::TCanvas(bool build = kTRUE) =>
takes at most 1 arguments (4 given)
TCanvas::TCanvas(const char* name, const char* title = “”, int form = 1) =>
takes at most 3 arguments (4 given)
TCanvas::TCanvas(const char* name, const char* title, int ww, int wh) =>
problem in C++; program state has been reset
TCanvas::TCanvas(const char* name, const char* title, int wtopx, int wtopy, int ww, int wh) =>
takes at least 6 arguments (4 given)
TCanvas::TCanvas(const char* name, int ww, int wh, int winid) =>
could not convert argument 2[/code]

Looks like some paths are still missing because files can’t be found?
Or has the canvas method been changed from Root 5.34 to 6 (I don’t think so)?

Thanks for your help!

Hi,

libASImage.so is linked to libpng12.so.0 and the loader, upon loading of the former, cannot find the latter:

cling::DynamicLibraryManager::loadLibrary(): libpng12.so.0: cannot open shared object file: No such file or directory

This happens if the file is not there at all or if its path is not in the LD_LIBRARY_PATH. We can exclude the first possibility, since ROOT works when sourcing the thisroot.sh script.
The reason could be linked to the fact that you overwrite the LD_LIBRARY_PATH variable in your script and not append to it.

Cheers,
Danilo

Well, even if I source thisroot and start python with:

import ROOT canvas = ROOT.TCanvas()

I get the same error.
What exactly do you mean with that I “overwrite the LD_LIBRARY_PATH variable in your script and not append to it.”?

I have a libASImage in my root folder but no libpng, is the second one missing or is it included in some other .so?

Cheers,
Michael

Edit: I’ve looked up which libpngs I have installed:

libpng.i686 2:1.5.13-7.el7_2 @sl-security libpng.x86_64 2:1.5.13-7.el7_2

I"ve tried to install libpng12, but it says

Resolving Dependencies --> Running transaction check ---> Package libpng12-devel.x86_64 0:1.2.50-7.el7_2 will be installed --> Processing Dependency: libpng12(x86-64) = 1.2.50-7.el7_2 for package: libpng12-devel-1.2.50-7.el7_2.x86_64 --> Processing Dependency: libpng12.so.0()(64bit) for package: libpng12-devel-1.2.50-7.el7_2.x86_64 --> Running transaction check ---> Package libpng12.x86_64 0:1.2.50-7.el7_2 will be installed --> Processing Conflict: libpng12-devel-1.2.50-7.el7_2.x86_64 conflicts libpng-devel --> Finished Dependency Resolution Error: libpng12-devel conflicts with 2:libpng-devel-1.5.13-7.el7_2.x86_64 You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest

and doesn’t install.

Hi,

I understood it was working for you. Apologies.

I am not sure what is wrong on your setup. You might try to create a symlink to the 64bit library called libpng12.so.0 .

Cheers,
Danilo

Hi,

sorry for my late reply:
I figured it out; bascially i just looked for the libpng12.so.0 file with a yum search command and installed the first package that was popping up.
Sadly I don’t know the details anymore, because I lost my post when I wanted to post it here in my last free seconds at the office 2 days ago (had to relogin because I waited too long with the post and then all was lost :frowning: ).

It looks like you just need to install an old version of libpng (called ‘libpng12-1.2.50-6.el7.x86_64’ and NOT libpng12.x86_64) or otherwise it won’t work (at least on my machine).
Anyways, it works now :slight_smile:

Thanks a lot for your help!

Cheers,
Michael