[Rivet] Rivet issue with PYTHONPATH variable

Andy Buckley andy.buckley at cern.ch
Mon Sep 28 12:52:09 BST 2015


Why not set PYTHONPATH to /opt/Rivet/lib64/python2.7/site-packages as 
your rivet-config output indicates? /opt/Rivet is the prefix you set, so 
you would not expect to have to specify locations in /usr

Andy


On 28/09/15 12:39, Maksym Deliyergiyev wrote:
> Hi Andy,
>
>  > All Rivet should require in PYTHONPATH is the path to the directory (or
>  > directories) containing the rivet and yoda Python modules. These modules
>
> It seems that Rivet was build properly according to the "rivet-config"dump:
> ------------------------------------------
> [root at maksym bin]# ./rivet-config --pythonpath --libs --libdir --includedir
> /opt/Rivet/include  /opt/Rivet/lib /
> opt/Rivet/lib64/python2.7/site-packages   -lRivet
> ------------------------------------------
>
> Nevertheless, with your advice in mind I removed the PYTHON  and  the
> Python3 from the setup of the environment variables.
> But once I tried to run Rivet it starts complaining:
> [root at maksym bin]# ./rivet --help
> The rivet Python module could not be loaded: is your PYTHONPATH set
> correctly?
>
> So, afterwards I even tried to copy the Rivet folder with python modules
> to the system path
> /usr/lib/python2.7/site-packages/
> /usr/lib64/python2.7/site-packages/
>
> And again I got the same messagethat PYTHONPATH does not set
> correctly.In addition, if I will run another Rivet executable fileit
> starts complaining that rivet module does not exist.
> ---------------------------------
> [root at maksym bin]# ./rivet-which
> Traceback (most recent call last):
>    File "./rivet-which", line 13, in <module>
>      import rivet, sys, os
> ImportError: No module named rivet
> ---------------------------------
>
>
> Do you have any ideas how to make it work?BTW, the Rivet installation
> was configured in the following way:
> ---------------------------------
> [blessed at maksym Rivet-2.2.1]$ ./configure --prefix=/opt/Rivet
> --exec-prefix=/opt/Rivet   --with-yoda=/opt/YODA
> --with-yoda-libpath=/opt/YODA/lib
> --with-yoda-incpath=/opt/YODA/include  --with-hepmc=/opt/HEPMC2
> --with-hepmc-libpath=/opt/HEPMC2/lib
> --with-hepmc-incpath=/opt/HEPMC2/include   --with-fastjet=/opt/FastJet
> --with-fastjet-libpath=/opt/FastJet/lib
> --with-fastjet-incpath=/opt/FastJet/include
> --with-gsl-incpath=/usr/local/include/gsl  PYTHON=/bin/python
>
> checking for python... /bin/python
> checking whether /bin/python version >= 2.5... yes
> checking for Python include path... /usr/include/python2.7
> configure: All Python build checks successful: 'yoda' Python extension
> will be built
> checking if the /usr/bin/g++ compiler accepts the
> -Wno-unused-but-set-variable flag... yes
> checking if the /usr/bin/g++ compiler accepts the -Wno-sign-compare
> flag... yes
> checking for python version... 2.7
> checking for python platform... linux2
> checking for python script directory...
> ${prefix}/lib/python2.7/site-packages
> checking for python extension module directory...
> ${exec_prefix}/lib64/python2.7/site-packages
> checking for Cython >= 0.18... yes
> configure: Cython >= 0.18 found: Python extension source can be rebuilt
> (for developers)
> configure: All Python build checks successful: 'rivet' Python extension
> will be built
> ---------------------------------
>
>
>
>
> Best regards,
> Max
>
>
>
>
>
>
>
>
>  > Subject: Re: [Rivet] Rivet issue with PYTHONPATH variable
>  > To: maksym.deliyergiyev at outlook.com; rivet at projects.hepforge.org
>  > From: andy.buckley at cern.ch
>  > Date: Mon, 28 Sep 2015 10:54:59 +0100
>  >
>  > Hi Max,
>  >
>  > I'm not sure what you are trying to do. Those paths look like
>  > system-level Python paths, which should be automatically searched by the
>  > active Python executable. In addition it doesn't make sense to have
>  > Python search module directories both for Python3 (which Rivet doesn't
>  > yet support) and Python2 -- you are either using one or the other!
>  >
>  > Your method 1 is setting a PYTHON variable as well as PYTHONPATH. I
>  > don't know if that has any effect, but note that $PYTHON is often used
>  > to refer to the python executable itself, so this could cause problems.
>  >
>  > Your method 2 implies some confusion over what rivet-config does: it
>  > just prints paths and config flags according to what was used to build
>  > and install Rivet, to help with consistency when building plugin modules
>  > or linking other codes against libRivet. It does not *set* the
>  > environment -- no executable can do that, because they can only modify
>  > the subshell that they execute in, which disappears when the program
>  > finishes.
>  >
>  > All Rivet should require in PYTHONPATH is the path to the directory (or
>  > directories) containing the rivet and yoda Python modules. These modules
>  > are actually directories, which contain files like __init__.py, other
>  > *.py files, and the C extensions which both cases are called core.so. I
>  > usually install into my home directory, and hence need to set
>  > PYTHONPATH; if you have installed into system paths like /usr or
>  > /usr/local then I suspect you should not need to set anything because
>  > e.g. /usr/lib64/pythonX.Y/site-packages should already be in the Python
>  > X.Y default search path.
>  >
>  > Andy
>  >
>  >
>  > On 28/09/15 10:38, Maksym Deliyergiyev wrote:
>  > > Dear Rivet developers,
>  > >
>  > > Could you please explain me how one should have to configure the
>  > > PYTHONPATH in order to force the Rivet application to work? I have
> tried
>  > > to setup this environment variable in several ways, but it seems the
>  > > Rivet still do not recognized it. The most weird thing that during the
>  > > configuration procedure the python is always found in the right place.
>  > >
>  > > Method 1:
>  > > ---------------------------------------------
>  > > export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/site-packages
>  > > export PYTHONPATH=$PYTHONPATH:/usr/lib/python3.4/site-packages
>  > > export PYTHONPATH=$PYTHONPATH:/usr/lib64/python2.7/site-packages
>  > > export PYTHONPATH=$PYTHONPATH:/usr/lib64/python3.4/site-packages
>  > > export PYTHONPATH=$PYTHONPATH:/usr/local/include/python3.4m
>  > > export PYTHONPATH=$PYTHONPATH:/usr/include/python2.74
>  > > export PYTHONPATH=$PYTHONPATH:/bin/python
>  > >
>  > >
>  > > export PYTHON=$PYTHON:/usr/lib/python2.7/site-packages
>  > > export PYTHON=$PYTHON:/usr/lib/python3.4/site-packages
>  > > export PYTHON=$PYTHON:/usr/lib64/python2.7/site-packages
>  > > export PYTHON=$PYTHON:/usr/lib64/python3.4/site-packages
>  > > export PYTHON=$PYTHON:/usr/local/include/python3.4m
>  > > export PYTHON=$PYTHON:/usr/include/python2.74
>  > > export PYTHON=$PYTHON:/bin/python
>  > > ---------------------------------------------
>  > >
>  > >
>  > > Method 2:
>  > > ---------------------------------------------
>  > > ./rivet-config --pythonpath=/usr/include/python3.4m
>  > > --libs=/usr/lib64/python3.4/site-packages --libdir=/opt/Rivet/lib
>  > > --includedir=/opt/Rivet/include
>  > > ---------------------------------------------
>  > >
>  > >
>  > > Method 3:
>  > > ---------------------------------------------
>  > > import os, sys
>  > >
>  > > ## Load the rivet module
>  > > try:
>  > > import rivet
>  > > except:
>  > > ## If rivet loading failed, try to bootstrap the Python path!
>  > > try:
>  > > # TODO: Is this a good idea? Maybe just notify the user that
>  > > their PYTHONPATH is wrong?
>  > > import commands
>  > > ...
>  > > ...
>  > > ...
>  > > sys.path.append('/usr/lib/python2.7/site-packages')
>  > > sys.path.append('/usr/lib/python3.4/site-packages')
>  > > sys.path.append('/usr/lib64/python2.7/site-packages')
>  > > sys.path.append('/usr/lib64/python3.4/site-packages')
>  > > sys.path.append('/usr/local/include/python3.4m')
>  > > sys.path.append('/usr/include/python2.74')
>  > > sys.path.append('/usr/include/python3.4m')
>  > > sys.path.append('/opt/Rivet/lib64/python2.7/site-packages')
>  > > sys.path.append('/bin/python')
>  > > import rivet
>  > > except:
>  > > sys.stderr.write("The rivet Python module could not be loaded:
>  > > is your PYTHONPATH set correctly?\n")
>  > > sys.exit(1)
>  > > ---------------------------------------------
>  > >
>  > >
>  > >
>  > >
>  > >
>  > > Thanks in advance,
>  > > Max
>  > >
>  > >
>  > > _______________________________________________
>  > > Rivet mailing list
>  > > Rivet at projects.hepforge.org
>  > > https://www.hepforge.org/lists/listinfo/rivet
>  > >
>  >
>  >
>  > --
>  > Dr Andy Buckley, Lecturer / Royal Society University Research Fellow
>  > Particle Physics Expt Group, University of Glasgow


-- 
Dr Andy Buckley, Lecturer / Royal Society University Research Fellow
Particle Physics Expt Group, University of Glasgow


More information about the Rivet mailing list