是否可以并行运行两个版本的Python?

时间:2022-05-07 06:07:21

I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5.

我已经学习了几个星期的Python,虽然我已经用Python 2.6.5成功开发了Google App Engine的应用程序,但它特别需要Python 2.5。

Being mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine. Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.

在上传应用程序时要注意兼容性问题(这是我在学习Python时我宁愿避免的情况),我想知道是否可以在同一台机器上安装2.5和2.6.5。理想情况下,我想使用2.6.5作为默认值,并配置GAE以某种方式使用2.5。

3 个解决方案

#1


4  

Absolutely.

If you're on *nix, you'd usually just use make altinstall instead of make install, that way the "python" binary won't get installed/overwritten, but instead you'd have e.g. python2.5 or python2.6 installed. Using a separate --prefix with the configure script is also an option, of course.

如果你在* nix上,你通常只使用make altinstall而不是make install,这样“python”二进制文件就不会被安装/覆盖,而是你可以用例如:安装了python2.5或python2.6。当然,也可以选择使用单独的--prefix和configure脚本。

Some Linux distributions will have multiple versions available via their package managers. They'll similarly be installed as python2.5 etc. (With the distribution's blessed/native version also installed as the regular python binary.)

一些Linux发行版将通过其包管理器提供多个版本。它们同样可以安装为python2.5等。(分发版的blessed / native版本也作为常规python二进制文件安装。)

Windows users generally just install to different directories.

Windows用户通常只安装到不同的目录。

#2


0  

Yes, it is possible to install multiple versions of Python "side-by-side". On Ubuntu, you simply install with

是的,可以“并排”安装多个版本的Python。在Ubuntu上,您只需安装

sudo apt-get install python2.5

(On the current version of Ubuntu, 10.04, python2.6 comes installed by default.) To use python 2.6, just call python or /usr/bin/python. To use python 2.5, you call /usr/bin/python2.5.

(在当前版本的Ubuntu,10.04中,默认安装了python2.6。)要使用python 2.6,只需调用python或/ usr / bin / python。要使用python 2.5,请调用/usr/bin/python2.5。

If you tell us your operating system, we may be able to provide more relevant details.

如果您告诉我们您的操作系统,我们可能会提供更多相关详细信息。

Another possibility is to use virtualenv.

另一种可能性是使用virtualenv。

#3


0  

OK, I figured out the answer to my own question, partly with the help of Nicholas Knight who pointed out that you just install different Python version to different Python directories. I was left scratching my head on how to get Google App Engine to use Python 2.5 (the required version) instead of Python 2.6. This is the answer:

好吧,我找到了自己问题的答案,部分是在Nicholas Knight的帮助下,他指出你只是在不同的Python目录中安装了不同的Python版本。我对如何让Google App Engine使用Python 2.5(所需版本)而不是Python 2.6感到很头疼。这就是答案:

1) Install Python 2.5. 2) Install Python 2.6 (or a more recent version), afterwards. This will be the system default. 3) Install the Google App Engine SDK. 4) Launch, "Google App Engine Launcher" from the Start Menu 5) Click Edit > Preferences, and enter the path to the pythonw.exe executable. Usually c:\Python25\pythonw.exe

1)安装Python 2.5。 2)之后安装Python 2.6(或更新的版本)。这将是系统默认值。 3)安装Google App Engine SDK。 4)从“开始”菜单启动“Google App Engine Launcher”5)单击“编辑”>“首选项”,然后输入pythonw.exe可执行文件的路径。通常是c:\ Python25 \ pythonw.exe

#1


4  

Absolutely.

If you're on *nix, you'd usually just use make altinstall instead of make install, that way the "python" binary won't get installed/overwritten, but instead you'd have e.g. python2.5 or python2.6 installed. Using a separate --prefix with the configure script is also an option, of course.

如果你在* nix上,你通常只使用make altinstall而不是make install,这样“python”二进制文件就不会被安装/覆盖,而是你可以用例如:安装了python2.5或python2.6。当然,也可以选择使用单独的--prefix和configure脚本。

Some Linux distributions will have multiple versions available via their package managers. They'll similarly be installed as python2.5 etc. (With the distribution's blessed/native version also installed as the regular python binary.)

一些Linux发行版将通过其包管理器提供多个版本。它们同样可以安装为python2.5等。(分发版的blessed / native版本也作为常规python二进制文件安装。)

Windows users generally just install to different directories.

Windows用户通常只安装到不同的目录。

#2


0  

Yes, it is possible to install multiple versions of Python "side-by-side". On Ubuntu, you simply install with

是的,可以“并排”安装多个版本的Python。在Ubuntu上,您只需安装

sudo apt-get install python2.5

(On the current version of Ubuntu, 10.04, python2.6 comes installed by default.) To use python 2.6, just call python or /usr/bin/python. To use python 2.5, you call /usr/bin/python2.5.

(在当前版本的Ubuntu,10.04中,默认安装了python2.6。)要使用python 2.6,只需调用python或/ usr / bin / python。要使用python 2.5,请调用/usr/bin/python2.5。

If you tell us your operating system, we may be able to provide more relevant details.

如果您告诉我们您的操作系统,我们可能会提供更多相关详细信息。

Another possibility is to use virtualenv.

另一种可能性是使用virtualenv。

#3


0  

OK, I figured out the answer to my own question, partly with the help of Nicholas Knight who pointed out that you just install different Python version to different Python directories. I was left scratching my head on how to get Google App Engine to use Python 2.5 (the required version) instead of Python 2.6. This is the answer:

好吧,我找到了自己问题的答案,部分是在Nicholas Knight的帮助下,他指出你只是在不同的Python目录中安装了不同的Python版本。我对如何让Google App Engine使用Python 2.5(所需版本)而不是Python 2.6感到很头疼。这就是答案:

1) Install Python 2.5. 2) Install Python 2.6 (or a more recent version), afterwards. This will be the system default. 3) Install the Google App Engine SDK. 4) Launch, "Google App Engine Launcher" from the Start Menu 5) Click Edit > Preferences, and enter the path to the pythonw.exe executable. Usually c:\Python25\pythonw.exe

1)安装Python 2.5。 2)之后安装Python 2.6(或更新的版本)。这将是系统默认值。 3)安装Google App Engine SDK。 4)从“开始”菜单启动“Google App Engine Launcher”5)单击“编辑”>“首选项”,然后输入pythonw.exe可执行文件的路径。通常是c:\ Python25 \ pythonw.exe