|
[Rivet] Rivet issue with PYTHONPATH variableAndy Buckley andy.buckley at cern.chMon Sep 28 10:54:59 BST 2015
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
More information about the Rivet mailing list |