Fail to access python version of LHAPDF?

Asked by Ruoquan Wang on 2020-11-13

I have python both 2.7 and 3.9 on my mac OS catalina.
lhapdf 6.2.1 is installed by homebrew:
I added the correct lhapdf path to PYTHONPATH and DYLD_LIBRARY_PATH

When i run madgraph5, i got this:

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).The required LD_LIBRARY_PATH is /usr/local/Cellar/lhapdf/6.2.1/lib

To try what happens, I tried to run python. When I run python2.7, import lhapdf, everything is OK. When I run python 3.9 and import lhapdf, I got this:

>>> import lhapdf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/usr/local/Cellar/lhapdf/6.2.1/lib/python2.7/site-packages/, 2): Symbol not found: _PyClass_Type
  Referenced from: /usr/local/Cellar/lhapdf/6.2.1/lib/python2.7/site-packages/
  Expected in: flat namespace
 in /usr/local/Cellar/lhapdf/6.2.1/lib/python2.7/site-packages/

Question information

English Edit question
MadGraph5_aMC@NLO Edit question
No assignee Edit question
Solved by:
Ruoquan Wang
Last query:
Last reply:

This question was reopened

Ruoquan Wang (isaac95) said : #1

Problem solved.
Do not trust the homebrew-hep now. It is out of date. Many configurations are not updated.
Just install lhapdf by hand. While configure, make sure to check the python version it get. If it is not python3, switch to python3 environment for the computer. Then we can get the python3 version for lhapdf.