Pyroot in Archlinux - Installation Problem

Hello everybody,

I have the following problem when I trying to compile pyroot:

Checking for Python.h … /usr/include/python3.3m/
Checking for python3.3, libpython3.3, libpython, python, or Python … no

In consequence I can’t import ROOT when execute python. I tried
./configure --with-python-incdir=/usr/include/python3.3m/ --with-python-libdir=/usr/lib64/python3.3/
./configure --with-python-incdir=/usr/include/python3.3m/ --with-python-libdir=/usr/lib32/python3.3/
./configure --with-python-incdir=/usr/include/python3.3m/ --with-python-libdir=/usr/lib/python3.3/
.
.
.and more, without success…

Any suggestions?

Hi,

does any of the libraries show contain libpython3.3.so, libpython.so, libpython3.3.a, or libpython3.3.a? If not, does it exist somewhere else on the system? Also, the choice of lib64 or lib32 should be based on the python executable used.

Note that p3.3 is rarely used with PyROOT. It should work (except for the buffer interface, which I still have to rewrite), but is otherwise little tested.

Cheers,
Wim

Hi,

Thanks for the answer,

Yes, those lib are in /usr/lib/:
libpython2.7.so libpython3.3m.so libpython3.so
libpython2.7.so.1.0 libpython3.3m.so.1.0

Also I tried to compile with python 2.7 and I have exactly the same problem
./configure --with-python-incdir=/usr/include/python2.7 --with-python-libdir=/usr/lib/ --enable-python

Hi,

so no, there’s no libpython3.3.so, but a libpython3.3m.so and the script does not look for that. Any chance of symlinking libpython3.3.so to libpython3.3m.so?

For python2.7 setup, make sure that which python refers to p2.7 for that to work, even with incdir and libdir set (python is used to pre-compile .py files).

Cheers,
Wim

Hi,

I created the symlink and now the configure script detect python, but now I have the following error compiling:

bindings/pyroot/src/TPython.o: In function TPython::LoadMacro(char const*)': TPython.cxx:(.text+0x624): undefined reference toPyClass_Type’
TPython.cxx:(.text+0x69a): undefined reference to PyString_Type' bindings/pyroot/src/Utility.o: In functionPyROOT::Utility::BuildTemplateName(_object*&, _object*, int)’:
Utility.cxx:(.text+0x7d2): undefined reference to PyString_FromString' Utility.cxx:(.text+0x7dd): undefined reference toPyString_ConcatAndDel’
Utility.cxx:(.text+0x817): undefined reference to PyString_Concat' Utility.cxx:(.text+0x82a): undefined reference toPyString_FromString’
Utility.cxx:(.text+0x835): undefined reference to PyString_ConcatAndDel' Utility.cxx:(.text+0x8b9): undefined reference toPyString_FromString’
Utility.cxx:(.text+0x8c4): undefined reference to PyString_ConcatAndDel' Utility.cxx:(.text+0x8f8): undefined reference toPyString_Size’
Utility.cxx:(.text+0x90b): undefined reference to PyString_FromString' Utility.cxx:(.text+0x916): undefined reference toPyString_ConcatAndDel’
bindings/pyroot/src/Utility.o: In function PyROOT::Utility::GetBuffer(_object*, char, int, void*&, bool)': Utility.cxx:(.text+0xb3f): undefined reference toPyString_FromFormat’
bindings/pyroot/src/Utility.o: In function `PyROOT::Utility::ErrMsgCallback(char*)’:
.
.And so on…
.
.
Until:

bindings/pyroot/src/PyStrings.o:PyStrings.cxx:(.text+0x19f): more undefined references to PyString_InternFromString' follow bindings/pyroot/src/TCustomPyTypes.o:(.data.rel+0x2a0): undefined reference toPyInt_Type’
collect2: error: ld returned 1 exit status
make: *** [lib/libPyROOT.so] Error 1

I tried with both python version and nothing…

Thanks in advance
Cheers
Roger

Roger,

which symlink and combination of flags to the configure script did you create? From the looks of it, this is a build against the p2 headers, and a link against the p3 library.

Cheers,
Wim

Hi,

This is the command used:

./configure --with-python-incdir=/usr/include/python3.3m/ --with-python-libdir=/usr/lib/

Inside /usr/lib I have:
libpython2.7.so libpython3.3m.so libpython3.3.so
libpython2.7.so.1.0 libpython3.3m.so.1.0 libpython3.so

the configure script output:
Checking for Python.h … /usr/include/python3.3m/
Checking for python3.3, libpython3.3, libpython, python, or Python … /usr/lib64/

Also I tried

./configure --with-python-incdir=/usr/include/python2.7/ --with-python-libdir=/usr/lib/

and nothing

Cheers
Roger

Roger,

so if /usr/lib64 is picked up, what is in there and where does libpython3.3.so point to? Or rather, is there perhaps a libpython.so that points to libpython2.7.so?

Cheers,
Wim

Hi,

I send you the output in order to be clear:

ls -l /usr/lib64/libpython*
lrwxrwxrwx 1 root root 19 May 12 11:31 /usr/lib64/libpython2.7.so -> libpython2.7.so.1.0
-r-xr-xr-x 1 root root 1997351 May 12 11:31 /usr/lib64/libpython2.7.so.1.0
lrwxrwxrwx 1 root root 20 Apr 6 18:45 /usr/lib64/libpython3.3m.so -> libpython3.3m.so.1.0
-r-xr-xr-x 1 root root 8481434 Apr 6 18:45 /usr/lib64/libpython3.3m.so.1.0
lrwxrwxrwx 1 root root 25 May 21 14:52 /usr/lib64/libpython3.3.so -> /usr/lib/libpython3.3m.so
-r-xr-xr-x 1 root root 7667 Apr 6 18:45 /usr/lib64/libpython3.so

and
ls -l /usr/lib/libpython*
lrwxrwxrwx 1 root root 19 May 12 11:31 /usr/lib/libpython2.7.so -> libpython2.7.so.1.0
-r-xr-xr-x 1 root root 1997351 May 12 11:31 /usr/lib/libpython2.7.so.1.0
lrwxrwxrwx 1 root root 20 Apr 6 18:45 /usr/lib/libpython3.3m.so -> libpython3.3m.so.1.0
-r-xr-xr-x 1 root root 8481434 Apr 6 18:45 /usr/lib/libpython3.3m.so.1.0
lrwxrwxrwx 1 root root 25 May 21 14:52 /usr/lib/libpython3.3.so -> /usr/lib/libpython3.3m.so
-r-xr-xr-x 1 root root 7667 Apr 6 18:45 /usr/lib/libpython3.so

as you can see there is no libpython.so

Roger,

but why this: /usr/lib64/libpython3.3.so -> /usr/lib/libpython3.3m.soas arguable the symlink in lib64 should point to the lib64 version rather than the lib32 version as has been done here, no?

Cheers,
Wim

Hi Wim,

The thing is that I only have installed the 64bit version (pretty sure), in this system /usr/lib and /usr/lib64 are the same, actually there is another folder called /usr/lib32 which doesn’t have any python library. In any case I changed what you suggested but I got the same error…

Cheers
Roger

Roger,

well … beats me then. Remains that the missing PyString… etc. (which are gone from p3.x) I can only explain if there’s a mix of p2.x and p3.x happening, but I’m not seeing where else there could be a mash-up.

Cheers,
Wim

Hi Roger,

This works for me (never tried python3, only python2).

Create system symlink python -> python2 instead of python3 (python 3.x is current default version on Archlinux)

cd /usr/bin
sudo rm python
sudo ln -s python2 python

Go to your directory where is your ROOT source code, e.g.:

cd /opt/rootgit

Checkout/clone ROOT source code of your choice (for git, similarly for svn), see root.cern.ch/drupal/content/inst … oot-source:

git clone http://root.cern.ch/git/root.git #if needed
cd root
git tag -l
git checkout -b v5-34-08 v5-34-08 #switch branch/tag

I always rather clean/distclean everything and then configure and compile the code

make clean
make distclean
./configure --enable-{minuit2,unuran,table,roofit,table,gdml} --with-python-incdir='/usr/include/python2.7' --with-python-libdir='/usr/lib/python2.7/'
make 

After the compilation, create back the default python system symlink

cd /usr/bin
sudo rm python
sudo ln -s python3 python

In new terminal you may try, e.g.,:

source /opt/rootgit/root/bin/thisroot.sh
alias ipython=ipython2
alias python=python2
echo ROOT version: `python -c 'import ROOT; print ROOT.gROOT.GetVersion()'`

should give you “ROOT version: 5.34/08” (if not then something went wrong … ).

Hope that helps.

Cheers,
Jiri

Hello Folks
I just recently installed ROOT with pyROOT support under Archlinux. I had some trouble with it and I like to share my experience.
It seems to me, that problems occure because Arch is by default using python 3.4 and pyROOT (ROOT version: 6.02/01) doesn’t seem to be fit for this at the moment. Please correct me if I’m wrong.

Jiri’s post did help a lot, but it was not successful for me.
Instead of

I had to create a link for the inclue and lib folder, so I did:

cd /usr/bin
sudo rm python
sudo ln -s python2.7 python
cd /usr/include
(rm was not needed)
sudo ln -s python2.7 python
cd /usr/lib/
(rm was not needed)
sudo ln -s python2.7 python

afterwards I was able to build root with pyROOT support via:
cd to rootfolder, for me:

make clean
make distclean
./configure linuxx8664gcc --enable-python 
make -j5

To check if build process was sucessfull, see if libPyROOT.so exists:

Also dont forget to set environment varables. If one wants to use pyROOT. Aditionally PYTHONPATH must be set. I use in my ~/.bashrc

export ROOTSYS=/opt/root
export PATH=$PATH:$ROOTSYS/bin 
export LD_LIBRARY_PATH=$ROOTSYS/lib
export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/bindings/pyroot

This aditional $ROOTSYS/bindings/pyroot was needen because otherwise ROOT.py was not found and I could not import ROOT in python.

As Jiri posted it might be a good idear to change the symlink in /usr/bin back because other programms might rely on that.

cd /usr/bin sudo rm python sudo ln -s python3 python

As far as I understand it, Jiri’s and my approach should be the same, but for some reason Jiri’s solution did not work for me.

Cheers Malte

Hi,

I just done compiling ROOT with pyROOT support and figured out a simple solution for the path problems (no deleted symlinks afterwards :wink: ).

./configure --with-python-incdir=/usr/include/python2.7/ --with-python-libdir={/usr/lib/python2.7/,/usr/lib/} --with-python=/usr/bin/python2

Crucial is the part --with-python-libdir={}. Without the two paths it won’t work (and that’s the reason I’m posting this!). I am running Arch Linux with python2.7 (and python3.5 as default link from /usr/bin/python).

Running this with python3.5 fails cause of undefined references of sth like ‘PyString_FromString’. Couldn’t figure out what’s wrong there.

Greetings

That API is gone from p3: has only char buffers and unicode strings. Can’t mix python versions anyway.

-Dom

The solution of swen without creating and delating the symlinks is, of course, better (I had a problem to find correct options for the ./configure).

Another solution how to install arbitrary ROOT version is to use conda - create an enviroment with a python version of your choice, activate it (which should pick up the correct python version) and compile/install ROOT from source as usual. This works for me (similar approach with pip did not work for me).

Have not tried myself but you may try to install ROOT 5 or 6 + python 2 or 3 as a already existing conda package (and rootpy if you want) : github.com/rootpy/rootpy/issues/642

The conda approach allows separation of a developement enviroment from the system one and more control over the versions of packages in the enviroment. It should be also much more portable solution.