首页 > 解决方案 > 已安装 Python 2.7 和 Python 3.7。如何在 Python 2.7 中使用 MadGraph?

问题描述

我正在使用用 python 编写的模拟软件 MadGraph。MadGraph 仅与 python 2.7 兼容。我的 MadGraph 使用 Python 3.7.4 安装在 /mnt/c/1 文件夹中,正如我在 /mnt/c/1 目录中键入 ls 时看到的那样。但是当我输入 /mnt/c/1 目录 python --version 我得到 python 2.7.15+。在 /mnt/c/1MG5_aMC_v2_6_6 目录中,我键入 ls 但找不到 python。当我在同一目录中键入 which python 时,我得到 /usr/bin/python。当我输入 ls bin 时,我只得到 MadGraph 而没有 python。

我的问题是如何让 python 2.7 与 MadGraph 一起工作。我可以在一定程度上使用 MadGraph。当我想在 MadGraph 中输入某个命令时,我收到此错误:

Total: 4 processes with 4 diagrams
MG5_aMC>display diagrams
Drawing Process: u u~ > z > mu+ mu- WEIGHTED<=4 @1
Wrote file /tmp/diagrams_1_uux_z_mupmum.eps
open /tmp/diagrams_1_uux_z_mupmum.eps
Drawing Process: c c~ > z > mu+ mu- WEIGHTED<=4 @1
Wrote file /tmp/diagrams_1_ccx_z_mupmum.eps
open /tmp/diagrams_1_ccx_z_mupmum.eps
Drawing Process: d d~ > z > mu+ mu- WEIGHTED<=4 @1
Unhandled exception in thread started by <function call at 
0x7fbbb476bc08>Wrote file /tmp/diagrams_1_ddx_z_mupmum.eps

Traceback (most recent call last):
open /tmp/diagrams_1_ddx_z_mupmum.eps
File "/usr/lib/python2.7/subprocess.py", line 172, in call
Drawing Process: s s~ > z > mu+ mu- WEIGHTED<=4 @1
Unhandled exception in thread started by <function call at 0x7fbbb476bc08>
Traceback (most recent call last):
File "/usr/lib/python2.7/subprocess.py", line 172, in call
return Popen(*popenargs, **kwargs).wait()
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
Wrote file /tmp/diagrams_1_ssx_z_mupmum.eps
open /tmp/diagrams_1_ssx_z_mupmum.eps
raise child_exception
time to draw 0.063835144043
raise child_exception
OSErrorOSError: [Errno 2] No such file or directory: [Errno 2] No such 
file or directory
MG5_aMC>
Unhandled exception in thread started by <function call at 0x7fbbb476bc08>
Traceback (most recent call last):
File "/usr/lib/python2.7/subprocess.py", line 172, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Unhandled exception in thread started by <function call at 0x7fbbb476bc08>
Traceback (most recent call last):
File "/usr/lib/python2.7/subprocess.py", line 172, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

我不明白为什么我会为这个特定命令(显示模拟/生成的进程图)收到此操作系统错误。我可以很好地模拟这个过程,但我无法显示图表。我最终遇到了上面的错误,它卡住了,我必须按 ctrl+c。我想知道是不是因为我安装了不同的python版本。我只是想了解这个用 python 编写的错误以及如何修复它。我真的很感激一些帮助。谢谢!

标签: pythonpython-2.7ubuntuoperating-system

解决方案


MisterMiyagi 是正确的 - 回溯显示 MadGraph 使用的是 Python 2.7。

但是,当您键入“命令”时,MadGraph 会尝试 Popen ()一些其他脚本或可执行文件。你得到一个“errno 2”异常:无论 MadGraph 试图打开什么脚本或可执行文件,它都无法在你当前的PATH中找到它。

建议:

  1. 尝试strace以确定 Popen 试图查找的确切文件。

  2. 修改您的 PATH 以包含此文件所在的目录。

请发回您找到的内容。


推荐阅读