2

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 scripts that use python 2.6 and I can't convert them since they use some modules that aren't available for python 3.1 atm. So I'm considering installing python 3.1 along with my python 2.6. I only found people on the internet that achieve that by compiling python from the source and use make altinstall instead of the classic make install. Anyway, I think compiling from the source is a bit complicated. I thought running two different versions of a program is easy on Linux (I run fedora 11 for the record). Any hint?

Thanks for reading.

thomas
  • 1,855
  • 4
  • 17
  • 19
  • I finnaly use the make altinstall which is the one recommended by the python 3.1 source readme. Fedora doesn't propose rmp for python3.1 yet and I don't know how to build one (and it seems quite complex) so I just compiled it by hand. Thank all :) – thomas Jul 09 '09 at 14:00

4 Answers4

5

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
  • 41,871
  • 30
  • 130
  • 181
  • Fedora repositories doesn't have package for now. I'll remember that fact for when I'll reconsider my distro choice :) – thomas Jul 09 '09 at 14:02
2

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
  • 8,480
  • 20
  • 99
  • 146
  • 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 Jul 05 '09 at 14:03
1

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
  • 384,516
  • 81
  • 508
  • 779
  • 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 Jul 05 '09 at 13:33
  • 1
    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 Jul 05 '09 at 23:31
0

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
  • 96,888
  • 11
  • 64
  • 71
  • 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 Jul 09 '09 at 14:01
  • You only need one symlink, to the actual python executable. – sykora Jul 09 '09 at 15:06