Fun with Feisty and Python 2.5 3

Posted by timgoh
on Saturday, April 14

EDIT (May 18, 2007):

Ok I noticed from my awstats that a decent percentage of my traffic comes from looking for this problem, some through Google and others through a thread from the Ubuntu forums. I did not expect my quick hack to be used by so many others (honestly at the time I didn’t even know if it would work for me in the long term), but hey whatever works.

My original post was written as a “hey look what I found” and not as a “here’s how you fix this problem”, so I’m posting a much more succinct version. (The past two paragraphs don’t count!)

Who this fix is for: This fix is if you need python 2.4 as your default Python version in Feisty.

Those who familiar with Linux may have already tried symlinking /usr/bin/python to /usr/bin/python2.4, but get this error message:

ValueError: the symlink /usr/bin/python does not point to the python default version. it must be reset to point to python2.5

Here’s how to downgrade your default version in Feisty to Python 2.4 without those errors. Be very aware of my disclaimer at the end of the post before you follow any of this.

1. If you haven’t already, symlink /usr/bin/python to /usr/bin/python2.4

sudo ln -s /usr/bin/python2.4 /usr/bin/python

2. Edit your /usr/share/python/debian_defaults/ file

sudo vim /usr/share/python/debian_defaults

The initial few lines should read:

[DEFAULT]
# the default python version
default-version = python2.5

3. Change the third line to read:

default-version = python2.4

That’s all.

Once again, please read the disclaimer at the end of this post before you try this. I have been developing in Python and running Python apps on my system for a month with this fix, and have not encountered any problems yet.

Now, a favor to ask. If this works for you, please leave a comment saying it did. If it doesn’t, please leave a comment saying so with the appropriate error messages.

This way future people who are directed here can be more (or less) confident about this hack. Wouldn’t this post have been more valuable to you when you came if there were a bunch of affirmations and fixes for certain situations?

Call me a comment whore if you like, but comments here would benefit everyone who comes here looking for a solution. Or comment on the Ubuntu official forums thread .

Original post follows…

Previous Post:

(I would subtitle this “The journey is worth more than the destination”)

So Feisty comes with Python 2.5.

Now that’s not a problem right? Just symlink your /usr/bin/python2.4 and switch when necessary.

Except switching is far too excessive – “sudo apt-get upgrade” had dpkg crapping out on me saying that python was not symlinked to python2.5. Since my current projects are not 2.5-ready, I would have to swap back and forth a lot. This is particularly annoying since the problem package in my case, “update-manager-core”, does not require 2.5 to work.

I tried setting up update-alternatives to ease this a little:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.4 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.5 1
sudo update-alternatives --config python

This method does not save that many keystrokes from manually symlinking as necessary, but it’s easier and has less room for error I suppose.

However, this does not work. update-alternatives will symlink /usr/bin/python to /etc/alternatives/python (which is symlinked to the appropriate python version in /usr/bin) , which will cause /usr/share/pycentral-data/pyversions.py to choke (it is hardcoded to check for a symlink in the /usr/bin directory1)

/usr/share/pycentral-data/pyversions.py lines 129-130:

if not _default_version in (debian_default, os.path.join('/usr/bin', debian_default)):
    raise ValueError, "the symlink /usr/bin/python does not point to the python default version. It must be reset to point to %s" % debian_default

While poking around here, I noticed that the default version is set in /usr/share/python/debian_defaults/

relevant snippets from /usr/share/pycentral-data/pyversions.py:

config.readfp(file('/usr/share/python/debian_defaults'))
_defaults = config
value = _defaults.get('DEFAULT', name)
### name == 'default-version' in this circumstance

So I merrily made my way to the debian_defaults file and set the default version to python2.4. Double-checked with Debian Python Policy to make sure I wasn’t doing anything catastrophic. The relevant details are in section 1.3.1, and from my understanding of it, the change I made is safe.

I verified this change against my original problem – dpkg throwing an error when upgrading/installing/removing “update-manager-core” with /usr/bin/python symlinked to /usr/bin/python2.4. Problem solved without having to switch the symlink to python2.5. So this change has fixed a bigger problem than I was originally trying to solve – I now cut down the amount of symlink switching instead of making switching more convenient!

This is a huge hack though. I wouldn’t recommend it. For one thing, my “python” package (like any default Feisty install) is for Python 2.5, which conflicts with my manual change to debian_defaults. I do intend to keep this change for now but revert the moment I notice any strange behavior.


1 That is a bug for some other time—surely that code needs to include the possibility of update-alternatives being used. It’s not like that’s some obscure corner case.

Edgy Release Party! 0

Posted by timgoh
on Thursday, November 02

So, Mark Shuttleworth was in my part of the world1 yesterday, and how could I pass up the chance to meet a fellow geek, and a pretty damn successful one at that?

The event was the Edgy Eft release party, and it was a blast. Maybe 400 people cramped into a small conference room, standing room only. Mark started off by giving a quick speech on why FOSS is better than the proprietary alternative, and then gave a brief introduction of new features in Edgy. All this was old hat to me, but it was definitely an experience to hear him speaking about it in person—hearing the passion and drive in his voice.

It was interesting for me to compare Mark’s presentation to the last FOSS leader I got to see live – rms. Both are very charismatic, persuasive speakers. But where Mark appeals more to your brain and your sense of logic, rms appeals more to your heart and principles – your sense of what is just.

The subsequent Q&A had lots of interesting questions, which I shan’t go into too much detail about here. Some of them resulted in answers I knew already, ie how Mark got rich, etc, but I enjoyed listening to his delivery anyway. He can tell a story pretty well.

One blight on the session – someone abused his shot at a question to launch into an edict of what he wanted fixed in Ubuntu right now. Reading from a prepared list, at that. What a jackass.

As time went on, I was worried I wasn’t going to get my own question in – I was all the way at the back of the room, and deemed it undignified to wave my hand around wildly or jump up and down each time the chance came up. So when I finally got my chance, I projected my voice across the room to ask, “Suppose you have 3 years to turn someone into a core Ubuntu developer at Canonical. What would your training plan be?”

His tripartite answer (coincidence, or did he mishear my question as “3 steps”, I don’t know) was:

  1. Get a job in a company which uses Linux.
  2. Explore forums, wikis, IRC, etc and learn how the community works
  3. Decide on a small project for yourself, and implement it, getting help from the community if necessary

Straightforward enough. I think a series of broad goals is much better than a road map of details like “Spend 3 months reading kernel source, then write a device driver, followed by…”. Often journeys are more fun when they aren’t planned and you’re feeling your way as you go along.

The evening ended, sadly, with many fanbois asking for and getting photo opportunities with Mark. I saw this as rather pointless, although the starstruck people with autograph books and camera-phones in tow probably waited all night for this chance. My take on this: the guy is not famous for his face2, he is famous for the gray matter behind it. If it was Jessica Alba I’d ask for a photo – not attempt an intellectual conversation. Conversely, I spurned the chance at a photo with Mr Shuttleworth to engage in a quick back-and-forth instead. Nothing too brainy, just a short conversation on Canonical and Ubuntu which drifted into music at one point. Unfortunately, it couldn’t be any longer, lest the autograph hunters behind me in line had to go home with their dreams shattered .

I had actually planned to write about Edgy and my experience with it thus far earlier, but decided that this would make an excellent precursor to it. Definitely one helluva night for me. More on Edgy Eft to follow!


1 39°54′20″N, 116°23′29″E

2 No insult intended of course