开发者

Is it possible to run two versions of Python side-by-side?

开发者 https://www.devze.com 2023-01-05 08:30 出处:网络
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.

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.

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.


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.

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

Windows users generally just install to different directories.


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

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.

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

Another possibility is to use virtualenv.


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:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号