python - 如何在 gem5 中同时使用 python 2.7 和 3?
问题描述
我有一台机器有两个 gem5-repository 实例:一个我保持最新,另一个使用我还不能更新的旧版本。
我使用的是 Ubuntu 16.04,目前的 gem5 版本已经弃用了 python 2.7。我推迟了升级我的操作系统,并使用了一些解决方法(恢复提交scons: Set the minimum scons version to 3.0
,并手动添加EM_RISCV
到src/base/loader/elf_object.cc
);然而,最近事情变得一团糟,所以我不得不这样做以使用 SCons 3 和 python3。
在尝试了 Ubuntu 18.04 和 20.04 之后,由于在某些 python 类中使用了元类,我仍然无法编译。
不过,真正的问题很清楚。即使我安装了python3(在/usr/bin/
),也找不到python3-config:
Info: Using Python config: python2.7-config
如何在同一台机器上同时使用 python 2.7 和 3 来编译不同版本的 gem5?
解决方案
如果 SCons 找不到 python3-config,请使用其位置手动覆盖 PYTHON_CONFIG,并设置适当的环境。
alias scons2="/usr/bin/env python2.7 $(which scons) PYTHON_CONFIG=$(which python2.7-config)"
alias scons3="/usr/bin/env python3 $(which scons) PYTHON_CONFIG=$(which python3-config)"
然后,编译更新的存储库:
scons3 -j5 ./build/ARM/gem5.opt
要编译需要 python 2.7 的版本:
scons2 -j5 ./build/ARM/gem5.opt
推荐阅读
- html - 有什么作用?在 HTML 绝对链接中的意思
- python - Python 类中的嵌套方法
- opencv - 是否必须在 cv2.undistort 上使用 cv2.getOptimalNewCameraMatrix()?
- javascript - 输入验证的价格比较
- ruby-on-rails - MongoDB + Rails 错误:命令查找需要身份验证
- node.js - 了解表 dtOptions 的属性
- kubernetes - 在 GCE 中设置自我管理的 Kubernetes。区域托管实例组要使用哪种持久性磁盘?
- nginx - 多个 Active Directory 域的 SSO 身份验证
- javascript - 刷新div的内容
- java - 我不明白这段代码背后的逻辑。有人可以向我解释它的真正作用和方式吗?