Setting up Linux to use a certain version of python for compile

本小妞迷上赌 提交于 2019-12-08 01:34:30

问题


I'm running Ubuntu to compile a set of code which requires python 2.4.

How can I setup a terminal launcher so that when I open that launcher all python related commands will use python 2.4 instead of the python 2.6 that is defaulted in Ubuntu?


回答1:


Set a bash alias in that shell session: alias python=python2.4 (assuming python2.4 is in your $PATH of course). This way you won't have to remember to explicitly type the 2.4 a zillion times in that terminal -- which is what bash aliases are for!-)




回答2:


Invoke the interpreter via python2.4 instead of using the default.




回答3:


For a permenant system wide change put a symbolic link to the version you want in place of /usr/bin/python. ie

rm /usr/bin/python; ln -s /usr/bin/python2.4 /usr/bin/python

gentoo has a program 'eselect' which is for just this kind of thing (listing versions of programs and setting the default), Ubuntu may have something analogous; you'd have to check their docs.




回答4:


Watch out for using the alias when wanting to use the python you want. If the python script uses $0 to figure out, how it was called, then uses that answer to execute another python script. The other script will be called with whatever version that matches the link name, not the version the link points to.



来源:https://stackoverflow.com/questions/2393054/setting-up-linux-to-use-a-certain-version-of-python-for-compile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!