简体   繁体   English

Autotools - 当Python 3可用时使用Python 2.7

[英]Autotools - Use Python 2.7 when Python 3 is available

I use Arch Linux. 我使用Arch Linux。 python --version returns Python 3.6.2, python2 --version (and python2.7 --version ) returns Python 2.7.13. python --version返回Python 3.6.2, python2 --version (和python2.7 --version )返回Python 2.7.13。 Automake searches for a python newer than 2.4 and finds python (3.6). Automake搜索比2.4更新的python并找到python (3.6)。 The project doesn't work with python 3, though. 但是,该项目不适用于python 3。 AM_PATH_PYTHON(<min-version>[,...]) doesn't allow one to specify a maximum version. AM_PATH_PYTHON(<min-version>[,...])不允许指定最大版本。

How can I have automake search for python2 if python is too new? 如果python太新,我怎么能自动搜索python2 Or is there a better way to deal with this problem? 或者有更好的方法来解决这个问题吗? Automake should still find python if it's the correct version because this build needs to be able to run on distributions that have older packages (for instance, Ubuntu 14.04). 如果它是正确的版本,Automake仍然应该找到python ,因为这个构建需要能够在具有旧包的发行版上运行(例如,Ubuntu 14.04)。

PYTHONAM_PATH_PYTHON设置为一个宝贵的变量 ,你可以在配置时覆盖它的选择:

$ PYTHON=python2 ./configure

Until it's fixed upstream, I would do something like: 直到它固定在上游,我会做类似的事情:

mkdir ~/autotools_bin/
ln -s /usr/bin/python2 ~/autotools_bin/python
export PATH="~/autotools_bin:$PATH"

Then it can only find python2 (named python) and your system isn't messed up, only processes you run with the changed PATH. 然后它只能找到python2(名为python)并且你的系统没有搞砸,只有你用改变的PATH运行的进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM