views:

1811

answers:

4

Hi there,

I'm currently toying with python at home and I'm planning to switch to python 3.1. The fact is that I have some script that use python 2.6 and I can't convert them since they use some module that aren't available for python 3.1 atm. So I'm considering installing python 3.1 along my python 2.6. I only found people on internet that achieve that by compiling python from source and use make altinstall instead of the classic make install. Anyway, I think compiling from source is a bit complicated. I thought running two different version of a program is easy on linux (I run fedora 11 for the record). Any hint?

Thanks for reading.

+1  A: 

You're not supposed to need to run them together.

2.6 already has all of the 3.0 features. You can enable those features with from __future__ import statements.

It's much simpler run 2.6 (with some from __future__ import) until everything you need is in 3.x, then switch.

S.Lott
I'm aware of the from __future__ import somefeature but I really want to use python 3.x since, as a hobbyist the time I need to complete a project is huge. And I bet that when I'll end my project, python 3.x will be more broadly used.Anyway, thank for your answer :)
thomas
The from future import feature has no cost. None. It does not increase the time required to develop software. You don't need to run two things at once. Just use 2.6 and migrate to 3.0 when (a) everything you depend on has been migrated and (b) there is user demand for a "pure 3.x" version. Until then, use 2.6 with from future and you can focus on the project not the infrastructure.
S.Lott
+2  A: 

Download the python version you want to have as an alternative, untar it, and when you configure it, use --prefix=/my/alt/dir

Cheers

Nik
niklassaers
Thank for your answer. It confirmed that I must compile by myself python, and just done it almost successfully (some modules are ùissing like tkinter).
thomas
+2  A: 

On my Linux system (Ubuntu Jaunty), I have Python 2.5, 2.6 and 3.0 installed, just by installing the binary (deb) packages 'python2.5', 'python2.6' and 'python3.0' using apt-get. Perhaps Fedora packages them and names them as RPMs in a similar way.

I can run the one I need from the command line just by typing e.g. python2.6. So I can also specify the one I want at the top of my script by putting e.g.:

#!/usr/bin/python2.6
Craig McQueen
Fedora repositories doesn't have package for now. I'll remember that fact for when I'll reconsider my distro choice :)
thomas
A: 

Why do you need to use make install at all? After having done make to compile python 3.x, just move the python folder somewhere, and create a symlink to the python executable in your ~/bin directory. Add that directory to your path if it isn't already, and you'll have a working python development version ready to be used. As long as the symlink itself is not named python (I've named mine py), you'll never experience any clashes.

An added benefit is that if you want to change to a new release of python 3.x, for example if you're following the beta releases, you simply download, compile and replace the folder with the new one.

It's slightly messy, but the messiness is confined to one directory, and I find it much more convenient than thinking about altinstalls and the like.

sykora
I prefer using make(alt)install as I'm not fond of making simlink every where. But this would certainly have worked as well as the make altinstall way. Thank !
thomas
You only need one symlink, to the actual python executable.
sykora