Trouble accessing python version of LHAPDF

Asked by Jake

Hi,

I'm trying to access the python version of LHAPDF for a study of the systematic uncertainties. I have the "use_syst" flag to "True", but when launching the process I get the error

"Failed to access python version of LHAPDF: If the python interface to LHAPDF is available on your system, try adding its location to the PYTHONPATH environment variable and theLHAPDF library location to LD_LIBRARY_PATH (linux) or DYLD_LIBRARY_PATH (mac os x)."

Following the advice on other questions, I have gone to /PATH/TO/LHAPDF6/lib/python2.7/site-packages/ and run "import lhapdf" in a python shell. I get the error

"Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libLHAPDF.so: cannot open shared object file: No such file or directory"

Furthermore I have tried "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:PATH/TO/LHAPDF6/lib/libLHAPDF.so" prior to trying to import lhapdf into python, but I get the same error.

I installed lhapdf6 directly from MadGraph and am using it out of the box. Any guidance would be much appreciated.

Thanks for your time,
Jake

Question information

Language:
English Edit question
Status:
Solved
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Solved by:
Olivier Mattelaer
Solved:
Last query:
Last reply:
Revision history for this message
Best Olivier Mattelaer (olivier-mattelaer) said :
#1

Hi,

I'm not expert on this. You might have better help from the lhapdf author. (likely from Andy)
They have a mailing list for the support.

For your test with
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:PATH/TO/LHAPDF6/lib/ibLHAPDF.so

you should actually not include the name of the so file in that line, but rather use
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:PATH/TO/LHAPDF6/lib/

Cheers,

Olivier

PS: if you are on mac the SIP might prevent python to have access to the LD_LIBRARY_PATH making the use of such variable irrelevant.

Revision history for this message
Jake (hasek05-06) said :
#2

Hi Olivier,

Thanks a lot! This fixed the issue with loading lhapdf into python, and thus MadGraph was able to perform systematics. To add more information in case anybody else has this issue, I'm running on Linux, not Mac.

One final question: in terms of SysCalc vs systematics, is there any advantage to one approach over the other?

Thanks again,
Jake

Revision history for this message
Christoph Imfeld (chris1991) said :
#4

Hi all,

Small addition to this, if anyone stumbles across the same message as a amateur concerning such things, and is not able to get it resolved with this instruction - this might be because this does not work precisely like this if you are using Linux via Ubuntu.
If so, try this, this resolved it for me:

https://stackoverflow.com/questions/13428910/how-to-set-the-environmental-variable-ld-library-path-in-linux

Best regards,
Christoph

Revision history for this message
Si Wang (siw34) said :
#5

Hi,

Here is a solution for it:
First in Madgraph:
MG5_aMC> install lhapdf6
MG5_aMC> set lhapdf /Path_to_folder/MG5_aMC_v3.5.0/HEPTools/lhapdf6_py3/bin/lhapdf-config

Later add in ~/.bashrc:
export PATH="/Path_to_folder/MG5_aMC_v3.5.0/HEPTools/lhapdf6_py3/bin:$PATH"
export LD_LIBRARY_PATH="/Path_to_folder/MG5_aMC_v3.5.0/HEPTools/lhapdf6_py3/lib:$LD_LIBRARY_PATH"
export PYTHONPATH="/Path_to_folder/MG5_aMC_v3.5.0/HEPTools/lhapdf6_py3/lib/python3.8/site-packages:$PYTHONPATH"
Then reboot.

Hope this helps,
Si