设置Linux使用特定版本的python进行编译

发布于 2024-08-23 21:24:48 字数 133 浏览 4 评论 0原文

我正在运行 Ubuntu 来编译一组需要 python 2.4 的代码。

如何设置终端启动器,以便当我打开该启动器时,所有与 python 相关的命令都将使用 python 2.4 而不是 Ubuntu 中默认的 python 2.6?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

娇俏 2024-08-30 21:24:50

通过 python2.4 调用解释器而不是使用默认值。

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

情栀口红 2024-08-30 21:24:50

对于永久性系统范围的更改,请放置指向所需版本的符号链接来代替 /usr/bin/python。即

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

gentoo 有一个程序 'eselect' 就是为了这种事情(列出程序版本并设置默认值),Ubuntu 可能有类似的东西;你必须检查他们的文档。

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.

一场信仰旅途 2024-08-30 21:24:50

当想要使用你想要的 python 时,请注意使用别名。如果 python 脚本使用 $0 来弄清楚它是如何被调用的,然后使用该答案来执行另一个 python 脚本。另一个脚本将使用与链接名称匹配的任何版本来调用,而不是链接指向的版本。

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.

水溶 2024-08-30 21:24:49

在该 shell 会话中设置一个 bash 别名:alias python=python2.4 (当然假设 python2.4 在您的 $PATH 中)。这样您就不必记住在该终端中显式输入 2.4 无数次——这就是 bash 别名的用途!-)

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!-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文