ImportError : No module named function_library

Asked by Roberto Franceschini on 2020-03-06

Hello,
  I just made UFO model with FeynRules Version: 2.3.36 ( 28 November 2019) and I am trying to load it in MG but there is an error for
`ImportError : No module named function_library`
I have checked I have this error in 2.6.0 and 2.7.0 as well.

The error goes away if I remove in write_param_card.py some import commands

#from __future__ import absolute_import
#from __future__ import print_function

but then the model does not generate processes with errors such as a
"generate e+ e- > e+ e-" with error:
KeyError : '1'

FYI I have noticed I get a "3 june 2010" version of write_param_card.py instead of "02 Aug 2012" i find in models shipped with MG (this is how I figured to remove the imports)
I am attaching the DEBUG file from the failed import usage of the plain model as generated from FeynRules.
Thanks for helping,
Roberto
#************************************************************
#* MadGraph5_aMC@NLO *
#* *
#* * * *
#* * * * * *
#* * * * * 5 * * * * *
#* * * * * *
#* * * *
#* *
#* *
#* VERSION 2.7.0 2020-01-20 *
#* *
#* The MadGraph5_aMC@NLO Development Team - Find us at *
#* https://server06.fynu.ucl.ac.be/projects/madgraph *
#* *
#************************************************************
#* *
#* Command File for MadGraph5_aMC@NLO *
#* *
#* run as ./bin/mg5_aMC filename *
#* *
#************************************************************
set default_unset_couplings 99
set group_subprocesses Auto
set ignore_six_quark_processes False
set loop_optimized_output True
set low_mem_multicore_nlo_generation False
set loop_color_flows False
set gauge unitary
set complex_mass_scheme False
set max_npoint_for_channel 0
import model sm
define p = g u c d s u~ c~ d~ s~
define j = g u c d s u~ c~ d~ s~
define l+ = e+ mu+
define l- = e- mu-
define vl = ve vm vt
define vl~ = ve~ vm~ vt~
import model SMplusGagammagamma
Traceback (most recent call last):
  File "/Users/roberto/MG5_aMC_v2_7_0/madgraph/interface/extended_cmd.py", line 1515, in onecmd
    return self.onecmd_orig(line, **opt)
  File "/Users/roberto/MG5_aMC_v2_7_0/madgraph/interface/extended_cmd.py", line 1464, in onecmd_orig
    return func(arg, **opt)
  File "/Users/roberto/MG5_aMC_v2_7_0/madgraph/interface/master_interface.py", line 278, in do_import
    self.cmd.do_import(self, *args, **opts)
  File "/Users/roberto/MG5_aMC_v2_7_0/madgraph/interface/madgraph_interface.py", line 5387, in do_import
    complex_mass_scheme=self.options['complex_mass_scheme'])
  File "/Users/roberto/MG5_aMC_v2_7_0/models/import_ufo.py", line 239, in import_model
    model = import_full_model(model_path, decay, prefix)
  File "/Users/roberto/MG5_aMC_v2_7_0/models/import_ufo.py", line 383, in import_full_model
    ufo_model = ufomodels.load_model(model_path, decay)
  File "/Users/roberto/MG5_aMC_v2_7_0/models/__init__.py", line 51, in load_model
    __import__(path_split[-1])
  File "/Users/roberto/MG5_aMC_v2_7_0/models/SMplusGagammagamma/__init__.py", line 8, in <module>
    import write_param_card
  File "/Users/roberto/MG5_aMC_v2_7_0/models/SMplusGagammagamma/write_param_card.py", line 8, in <module>
    from function_library import *
ImportError: No module named function_library
                          MadGraph5_aMC@NLO Options
                          ----------------
        complex_mass_scheme : False
    default_unset_couplings : 99
                      gauge : unitary
         group_subprocesses : Auto
  ignore_six_quark_processes : False
           loop_color_flows : False
      loop_optimized_output : True
  low_mem_multicore_nlo_generation : False
     max_npoint_for_channel : 0
               stdout_level : 20 (user set)

                         MadEvent Options
                          ----------------
     automatic_html_opening : True
                    nb_core : None
        notification_center : True
                   run_mode : 2

                      Configuration Options
                      ---------------------
                        OLP : MadLoop
                    amcfast : amcfast-config
                   applgrid : applgrid-config
                auto_update : 7
         cluster_local_path : None
           cluster_nb_retry : 1
              cluster_queue : None (user set)
         cluster_retry_wait : 300
               cluster_size : 100
      cluster_status_update : (600, 30)
          cluster_temp_path : None
               cluster_type : condor
                    collier : ./HEPTools/lib
               cpp_compiler : None
             crash_on_error : False
               delphes_path : ./Delphes
                 eps_viewer : None
        exrootanalysis_path : ./ExRootAnalysis
              f2py_compiler : None
                    fastjet : fastjet-config
           fortran_compiler : None
                      golem : None (user set)
                 hepmc_path : None (user set)
                  hwpp_path : None (user set)
                     lhapdf : lhapdf-config
          madanalysis5_path : None (user set)
           madanalysis_path : ./MadAnalysis
  mg5amc_py8_interface_path : None (user set)
                      ninja : ./HEPTools/lib
        output_dependencies : external
                      pjfry : None (user set)
            pythia-pgs_path : ./pythia-pgs
               pythia8_path : None (user set)
                    samurai : None
               syscalc_path : ./SysCalc
                    td_path : ./td
                text_editor : None
                thepeg_path : None (user set)
                    timeout : 60
                web_browser : None

Question information

Language:
English Edit question
Status:
Solved
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Solved by:
Olivier Mattelaer
Solved:
2020-03-08
Last query:
2020-03-08
Last reply:
2020-03-06

Hi,

The latest version of Feynrules should not have those lines anymore if I'm correct.
(I will try to cross-check that as soon as I have internet back).

> but then the model does not generate processes with errors such as a
> "generate e+ e- > e+ e-" with error:
> KeyError : '1'

This is a standard issue of having coupling not associated to any coupling order.
You can check the FAQ of madgraph, we have one on that topic (even if the answer is just a referende to the FR paper)

Cheers,

Olivier

> On 6 Mar 2020, at 15:16, Roberto Franceschini <email address hidden> wrote:
>
> New question #689170 on MadGraph5_aMC@NLO:
> https://answers.launchpad.net/mg5amcnlo/+question/689170
>
> Hello,
> I just made UFO model with FeynRules Version: 2.3.36 ( 28 November 2019) and I am trying to load it in MG but there is an error for
> `ImportError : No module named function_library`
> I have checked I have this error in 2.6.0 and 2.7.0 as well.
>
> The error goes away if I remove in write_param_card.py some import commands
>
>
> #from __future__ import absolute_import
> #from __future__ import print_function
>
> but then the model does not generate processes with errors such as a
> "generate e+ e- > e+ e-" with error:
> KeyError : '1'
>
> FYI I have noticed I get a "3 june 2010" version of write_param_card.py instead of "02 Aug 2012" i find in models shipped with MG (this is how I figured to remove the imports)
> I am attaching the DEBUG file from the failed import usage of the plain model as generated from FeynRules.
> Thanks for helping,
> Roberto
> #************************************************************
> #* MadGraph5_aMC@NLO *
> #* *
> #* * * *
> #* * * * * *
> #* * * * * 5 * * * * *
> #* * * * * *
> #* * * *
> #* *
> #* *
> #* VERSION 2.7.0 2020-01-20 *
> #* *
> #* The MadGraph5_aMC@NLO Development Team - Find us at *
> #* https://server06.fynu.ucl.ac.be/projects/madgraph *
> #* *
> #************************************************************
> #* *
> #* Command File for MadGraph5_aMC@NLO *
> #* *
> #* run as ./bin/mg5_aMC filename *
> #* *
> #************************************************************
> set default_unset_couplings 99
> set group_subprocesses Auto
> set ignore_six_quark_processes False
> set loop_optimized_output True
> set low_mem_multicore_nlo_generation False
> set loop_color_flows False
> set gauge unitary
> set complex_mass_scheme False
> set max_npoint_for_channel 0
> import model sm
> define p = g u c d s u~ c~ d~ s~
> define j = g u c d s u~ c~ d~ s~
> define l+ = e+ mu+
> define l- = e- mu-
> define vl = ve vm vt
> define vl~ = ve~ vm~ vt~
> import model SMplusGagammagamma
> Traceback (most recent call last):
> File "/Users/roberto/MG5_aMC_v2_7_0/madgraph/interface/extended_cmd.py", line 1515, in onecmd
> return self.onecmd_orig(line, **opt)
> File "/Users/roberto/MG5_aMC_v2_7_0/madgraph/interface/extended_cmd.py", line 1464, in onecmd_orig
> return func(arg, **opt)
> File "/Users/roberto/MG5_aMC_v2_7_0/madgraph/interface/master_interface.py", line 278, in do_import
> self.cmd.do_import(self, *args, **opts)
> File "/Users/roberto/MG5_aMC_v2_7_0/madgraph/interface/madgraph_interface.py", line 5387, in do_import
> complex_mass_scheme=self.options['complex_mass_scheme'])
> File "/Users/roberto/MG5_aMC_v2_7_0/models/import_ufo.py", line 239, in import_model
> model = import_full_model(model_path, decay, prefix)
> File "/Users/roberto/MG5_aMC_v2_7_0/models/import_ufo.py", line 383, in import_full_model
> ufo_model = ufomodels.load_model(model_path, decay)
> File "/Users/roberto/MG5_aMC_v2_7_0/models/__init__.py", line 51, in load_model
> __import__(path_split[-1])
> File "/Users/roberto/MG5_aMC_v2_7_0/models/SMplusGagammagamma/__init__.py", line 8, in <module>
> import write_param_card
> File "/Users/roberto/MG5_aMC_v2_7_0/models/SMplusGagammagamma/write_param_card.py", line 8, in <module>
> from function_library import *
> ImportError: No module named function_library
> MadGraph5_aMC@NLO Options
> ----------------
> complex_mass_scheme : False
> default_unset_couplings : 99
> gauge : unitary
> group_subprocesses : Auto
> ignore_six_quark_processes : False
> loop_color_flows : False
> loop_optimized_output : True
> low_mem_multicore_nlo_generation : False
> max_npoint_for_channel : 0
> stdout_level : 20 (user set)
>
> MadEvent Options
> ----------------
> automatic_html_opening : True
> nb_core : None
> notification_center : True
> run_mode : 2
>
> Configuration Options
> ---------------------
> OLP : MadLoop
> amcfast : amcfast-config
> applgrid : applgrid-config
> auto_update : 7
> cluster_local_path : None
> cluster_nb_retry : 1
> cluster_queue : None (user set)
> cluster_retry_wait : 300
> cluster_size : 100
> cluster_status_update : (600, 30)
> cluster_temp_path : None
> cluster_type : condor
> collier : ./HEPTools/lib
> cpp_compiler : None
> crash_on_error : False
> delphes_path : ./Delphes
> eps_viewer : None
> exrootanalysis_path : ./ExRootAnalysis
> f2py_compiler : None
> fastjet : fastjet-config
> fortran_compiler : None
> golem : None (user set)
> hepmc_path : None (user set)
> hwpp_path : None (user set)
> lhapdf : lhapdf-config
> madanalysis5_path : None (user set)
> madanalysis_path : ./MadAnalysis
> mg5amc_py8_interface_path : None (user set)
> ninja : ./HEPTools/lib
> output_dependencies : external
> pjfry : None (user set)
> pythia-pgs_path : ./pythia-pgs
> pythia8_path : None (user set)
> samurai : None
> syscalc_path : ./SysCalc
> td_path : ./td
> text_editor : None
> thepeg_path : None (user set)
> timeout : 60
> web_browser : None
>
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Hi Olivier, thanks for this input.
   I had all parameters defined with an InteractionOrder rule, e.g. InteractionOrder -> { NPA,1}, but the lagrangian had an interaction with no couplings whatsoever (I made it just to verify the FeynmanRule at first, then forgot it).

I got again FR from the website, this new "fresh from download" produced yet another write_param_card.py. This is without the

#from __future__ import absolute_import
#from __future__ import print_function

lines and also writes
__date__ = "6 March 2020"
I am puzzled, but this at least fixed the import.
Thanks again, this issue seems to be gone.

Best,
Roberto

Thanks Olivier Mattelaer, that solved my question.