Problem in installing pyroot

Dear PYROOT expert:

I am trying to install PYROOT on my local machine with the following command:

./configure --with-python-incdir= --with-python-libdir=

I can find the path which containts the libpythonx.y.so
[qing1981] /home/qing/software/root > ls /usr/lib64/libpython2.4.so
/usr/lib64/libpython2.4.so

But I can’t find Python.h from my local machine:

[qing1981] /home/qing/software/root > locate Python | grep Python.h
/usr/share/doc/swig-1.3.29/Manual/Python.html

Any idea that how should I proceed?

Thanks,Gang

Hi,

I have downloaded and installed python 2.6.5. now I can find Python. h:
[qing1981] /home/qing/software/Python-2.6.5 > ls /usr/local/include/python2.6/Python.h
/usr/local/include/python2.6/Python.h

but i can not find libpythonx.y.so in /usr/loca/lib/
[qing1981] /home/qing/software/Python-2.6.5 > ls /usr/local/lib/
libpython2.6.a python2.6/

Any idea?

Thanks,Gang

Gang,

if you install python from source, supply --enable-shared to configure to enable the shared library. That said, in theory linking to the archive library should work.

Cheers,
Wim

Hi, Wlav:

I donwloaded Python2.7.1 and then ’ ./configufure–enable-shared’ , then ‘gmake’

Both ‘Python.h’ and ‘libpython2.7.so’ are created:

[pcncu17] /scratch/qing/software/root > ls /scratch/qing/software/Python-2.7.1/Include/Python.h
/scratch/qing/software/Python-2.7.1/Include/Python.h
[pcncu17] /scratch/qing/software/root > ls /scratch/qing/software/Python-2.7.1/libpython2.7.so
/scratch/qing/software/Python-2.7.1/libpython2.7.so

Then I downlaoded root and ‘
./configure --with-python-incdir=/scratch/qing/software/Python-2.7.1/Include/Python.h --with-python-libdir=/scratch/qing/software/Python-2.7.1/libpython2.7.so > tmp’

[pcncu17] /scratch/qing/software/root > cat tmp | grep Python
Checking for Python.h … no
Checking for python2.4, libpython2.4, libpython, python, or Python … no

Seems ROOT still could not find python.h and the python lib, any idea?

–enable-shared

Hi, WALV:

seems pthon is not installed correctly;

[pcncu17] /scratch/qing/software/root > …/Python-2.7.1/python
…/Python-2.7.1/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

any idea?

Thanks,Gang

Hi,

the --with-python-incdir/libdir parameters take the directories, not the actual .h and .so. For running python from a different location, PATH and LD_LIBRARY_PATH need to be set to point to the executable and the shared library, respectively. Finally, not that after “gmake”, you’ll still need to run “gmake install” which installs python and all its modules in the directory specified with --prefix to ./configure (or in /usr/local by default).

Cheers,
Wim

Hi, Wlav:

Thanks, now i can run PYROOT! I put a full log here so next time I won’t forget it.

#install python
wget python.org/ftp/python/2.4.6/Python-2.4.6.tgz
tar -xvzf Python-2.4.6.tgz
cd Python-2.4.6
./configure --enable-shared
gmake
sudo gmake install

install pyroot

wget ftp://root.cern.ch/root/root_v5.28.00b.source.tar.gz
./configure --with-python-incdir=/usr/local/include/python2.4 --with-python-libdir=/usr/local/lib/
gmake

Cheers,Gang

Hello!

I installed ROOT with config:
./configure linux --enable-python --with-python-incdir=/usr/include/python2.6/Python.h --with-python-libdir=/usr/lib/libpython2.6.so

I use Ubuntu and this is my standard python.
In config.log:
Checking for python, libpython, libpython, python, or Python …
libraries to check for: python.so python.sl python.dylib python.dll.a libpython.so libpython.sl libpython.dylib libpython.dll.a libpython.so libpython.sl libpython.dylib libpython.dll.a python.so python.sl python.dylib python.dll.a Python.so Python.sl Python.dylib Python.dll.a python.a python.lib python libpython.a libpython.lib libpython libpython.a libpython.lib libpython python.a python.lib python Python.a Python.lib Python
Checking in directories /usr/lib/libpython2.6.so for python.so python.sl python.dylib python.dll.a libpython.so libpython.sl libpython.dylib libpython.dll.a libpython.so libpython.sl libpython.dylib libpython.dll.a python.so python.sl python.dylib python.dll.a Python.so Python.sl Python.dylib Python.dll.a python.a python.lib python libpython.a libpython.lib libpython libpython.a libpython.lib libpython python.a python.lib python Python.a Python.lib Python
library not found !!!

And doesn’t generate libPyROOT.so and ROOT.py after sudo make.

after that i installed python 2.7 with:
./configure --enable-shared
after that config root like:
./configure linux --with-python-incdir=/usr/local/include/python2.7 --with-python-libdir=/usr/local/lib/python2.7

And can’t find again:
Checking for library python.so in directory /usr/local/lib/python2.7
Checking /usr/local/lib/python2.7/python.so
python.so not found in /usr/local/lib/python2.7
Checking for library python.sl in directory /usr/local/lib/python2.7
Checking /usr/local/lib/python2.7/python.sl
python.sl not found in /usr/local/lib/python2.7
Checking for library python.dylib in directory /usr/local/lib/python2.7
Checking /usr/local/lib/python2.7/python.dylib
python.dylib not found in /usr/local/lib/python2.7
Checking for library python.dll.a in directory /usr/local/lib/python2.7
Checking /usr/local/lib/python2.7/python.dll.a
python.dll.a not found in /usr/local/lib/python2.7
etc…

Do you have any idea?
Thank you

Hi,

for the first (p2.6): --with-python-inc/libdir should point to the dirs, not the files. For the second (p2.7): the standard location is /usr/local/lib not /usr/local/lib/python2.7. Note that if python is installed in a standard location and the version that you want is available through PATH, the standard locations will be found automatically.

Cheers,
Wim

Hello,

Thank you for your reply!
I tried it like you wrote without success.

Than I reinstalled, ubuntu and all Prerequisites.
Now my config:
./configure --prefix=/usr/local

I attached my config.log file.

If you search for python in it, it can’t find again.

Could you help please?
config.tar.gz (12.6 KB)

I have done make with that config.
And i have now: /usr/local/lib/root/libPyROOT.so and /usr/local/lib/root/ROOT.py

But :
augre@lilian:~$ root
/usr/local/bin/root.exe: error while loading shared libraries: libCore.so: cannot open shared object file: No such file or directory

And I set
augre@lilian:~$ echo $PYTHONPATH
/usr/local/lib:

but python can’t import ROOT

This:
root.cern.ch/phpBB2/viewtopic.ph … ht=libcore
solved the first problem.
root runs :smiley:
had to add
/usr/local/lib/root

to a root.conf in /etc/ld.so.conf.d/

but python not yet

i did :

import sys
sys.path.append("/usr/local/lib/root")

and i can import ROOT :smiley:

Hi,

you can also simply add /usr/local/lib/root to PYTHONPATH.

Cheers,
Wim

Dear Wlav:

The following configuration works for python2.4.6 and ROOT_5.28:

#install python
wget python.org/ftp/python/2.4.6/Python-2.4.6.tgz
tar -xvzf Python-2.4.6.tgz
cd Python-2.4.6
./configure --enable-shared
gmake
sudo gmake install

install pyroot

wget ftp://root.cern.ch/root/root_v5.28.00b.source.tar.gz
./configure --with-python-incdir=/usr/local/include/python2.4 --with-python-libdir=/usr/local/lib/
gmake

But when I try python 2.6 and ROOT 5.32, the following error appeared:
python: error while loading shared libraries: libpython2.6.so.1.0: cannot open shared object file: No such file or directory

Any idea?

Cheers,Gang

Gang,

where is “libpython2.6.so.1.0” located and is it accessible through LD_LIBRARY_PATH?

Cheers,
Wim

That version of ROOT didn’t set etcdir correctly, so we should use a new format:

#install python
cd /work/users/qing/software
mkdir python2.4
wget python.org/ftp/python/2.4.6/Python-2.4.6.tgz
tar -xvzf Python-2.4.6.tgz
cd Python-2.4.6
./configure --enable-shared --prefix="/work/users/qing/software/python2.4"
gmake
gmake install

install pyroot

cd /work/users/qing/software
mkdir root5.28
wget ftp://root.cern.ch/root/root_v5.28.00b.source.tar.gz
tar -xvzf root_v5.28.00b.source.tar.gz
cd root
./configure --with-python-incdir=/work/users/qing/software/python2.4/include/python2.4 --with-python-libdir=/work/users/qing/software/python2.4/lib --prefix="/work/users/qing/software/root/root5.28" --etcdir="/work/users/qing/software/root/root5.28/etc"
gmake
gmake install

Environment setup before using ROOT:

export ROOTSYS=/work/users/qing/software/root
export PATH=/work/users/qing/software/python2.4/bin:$ROOTSYS/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib:/work/users/qing/software/python2.4/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$PYTHONPATH:$ROOTSYS/lib

Cheers,Gang

most common reason for this error is easily fixed. just do
sudo apt-get install python-dev
this way you can use the build-in python in your linux (works in Ubuntu tested should be fine in most other distribs)