MadAnalysis5 issue with python

Asked by Abideh Jafari

I have latest version of madgraph on my ubuntu 20.04 which has python3 as default.
To install MadAnalysis5, I created a virtual environment based on python2.7, there I installed the six package (so it is really under python2), I forced madgraph to run with python2.7 and I installed MadAnalysis5 successfully.

Now to use it, in the same environment, I launch a process (p p > t t~), and I get this complain which prevents MadAnalysis5 from running:
"MadAnalysis5 is not python3 compatible"

I know it is not python3 compatible and I did whatever to make sure my madgraph runs with python 2. Do you have any idea what is wrong?

Thanks a lot,
Nadjieh

Some input:
$ export VIRTUALENVWRAPPER_PYTHON="/usr/bin/python3"
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv -p /usr/bin/python2.7 p2
(p2) $ python -V [Python2.7.18]
(p2) $ python2.7 ./bin/mg5_aMC
THEN THE USUAL COMMANDS UNTIL LAUNCH,
INFO: MadAnalysis5 is not python3 compatible

Question information

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

Not sure to understand that since the code is the following:
madgraph/interface/common_run_interface.py (line 2452)

        try:
            from madanalysis.interpreter.ma5_interpreter import MA5Interpreter
            with misc.stdchannel_redirected(sys.stdout, os.devnull):
                with misc.stdchannel_redirected(sys.stderr, os.devnull):
                    MA5_interpreter = MA5Interpreter(MA5path, LoggerLevel=loglevel,
                                                     LoggerStream=logstream,forced=forced,
                                                     no_compilation=not compilation)
        except Exception as e:
            if six.PY3 and not __debug__:
                logger.info('MadAnalysis5 instalation not python3 compatible')
                return None
            logger.warning('MadAnalysis5 failed to start so that MA5 analysis will be skipped.')
            error=StringIO.StringIO()
            traceback.print_exc(file=error)
            logger.debug('MadAnalysis5 error was:')
            logger.debug('-'*60)
            logger.debug(error.getvalue()[:-1])
            logger.debug('-'*60)
            MA5_interpreter = None

So you can see that:
1) We try to load MA5 independently of the python version (such that it will work when the python3 release of MA5 will be released)
2) that warning appears only if six.PY3 is set on True (which should not be the case if you run python2.

I have try to run with python2.7 and did not face that issue. Maybe one solution would be to comment the lines
if six.PY3 and not __debug__:
                logger.info('MadAnalysis5 instalation not python3 compatible')
                return None
and run as
python2.7 ./bin/mg5_aMC -l DEBUG

This can give more information on why MA5 was crashing...

Olivier

PS: It is also important to understand if indeed you have an issue with the parameter six.PY3 since the full code will crash if you have that one to True when running python2

Revision history for this message
Abideh Jafari (ajafari) said :
#2

Hi Olivier,

Commenting those lines, no error or crash happens. Things run smoothly but no pdf file (as a result of MadAnalysis) is produced.
Below I copied what is there after running the MadAnalysis.
Other debugging messages are all before this and seem harmless.

Cheers,
Nadjieh

========

INFO: Running MadAnalysis5 [arXiv:1206.1599]
INFO: Parton input file considered:
INFO: --> /Users/vahid/Documents/MG5_aMC_v2_8_2/test/Events/run_17/unweighted_events.lhe.gz
INFO: Finished MA5 analyses.
INFO: storing files of previous run
INFO: Done
quit
INFO:
more information in /Users/vahid/Documents/MG5_aMC_v2_8_2/test/index.html
MG5_aMC>

Revision history for this message
Kentarou Mawatari (kentarou-mawatari) said :
#3

Hi Olivier,

I also have a similar problem with v.2.8.2. I followed your suggestion above and did

python2.7 ./bin/mg5_aMC -l DEBUG

then, MA5 installation looks successful. When generating a process and output,
MG5aMC tells

INFO: Generating MadAnalysis5 default cards tailored to this process
INFO: MadAnalysis5 instalation not python3 compatible

But, in the end madanalysis5_parton_card.dat is empty like

# This card is used only if MA5 failed to create a default for this run
# We therefore use as default: do nothing
@MG5aMC skip_analysis
PROC_sm_4/Cards/madanalysis5_parton_card_default.dat (END)

So, there is no plot...

Best regards,
Kentarou

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#4

First things to check is the following:

python2.7
import six
six.PY3

If six.PY3 is True, then you have an issue with the version of "six" that you are using.

Second would be to comment those two lines:
            with misc.stdchannel_redirected(sys.stdout, os.devnull):
                with misc.stdchannel_redirected(sys.stderr, os.devnull):

To see the output of MA5 on screen.

If nothing works, the only solution is to install the beta version of MA5 which supports python3:
https://code.launchpad.net/~ma5dev/madanalysis5/v1.9_beta

Cheers,

Olivier

Can you help with this problem?

Provide an answer of your own, or ask Abideh Jafari for more information if necessary.

To post a message you must log in.