强制使用 python2?
Force make to use python2?
我正在尝试使用 make
命令构建 Android 内核。该脚本使用 python2
以 print >> sys.stderr, line
方式记录错误。因此,我得到的不是实际的错误输出,而是关于不正确的 python 语法的错误。
我有删除 python3
的想法,但我读到它可能对系统有害,因为它是捆绑的,许多事情可能都依赖于它。尝试在 .bashrc
文件末尾添加 alias python=python2
,重新启动终端,用以下行对其进行测试:
echo `python -c "print 'test'"` # prints 'test' correctly
但是当我 make
时,我仍然会遇到同样的错误,它无论如何都设法使用 python3
。
我的错误在哪里?
您没有显示您的 Makefile。最简单的方法是在您的系统上定义 python 的绝对路径。您可以使用 which
命令获得它。然后,将 Makefile 中的 python
更改为您使用 which python2
.
找到的绝对路径
我正在尝试使用 make
命令构建 Android 内核。该脚本使用 python2
以 print >> sys.stderr, line
方式记录错误。因此,我得到的不是实际的错误输出,而是关于不正确的 python 语法的错误。
我有删除 python3
的想法,但我读到它可能对系统有害,因为它是捆绑的,许多事情可能都依赖于它。尝试在 .bashrc
文件末尾添加 alias python=python2
,重新启动终端,用以下行对其进行测试:
echo `python -c "print 'test'"` # prints 'test' correctly
但是当我 make
时,我仍然会遇到同样的错误,它无论如何都设法使用 python3
。
我的错误在哪里?
您没有显示您的 Makefile。最简单的方法是在您的系统上定义 python 的绝对路径。您可以使用 which
命令获得它。然后,将 Makefile 中的 python
更改为您使用 which python2
.