instal python-uno broken: /usr/bin/pycentral::default_runtime.remove_byte_code() : 'NoneType' object

Bug #75557 reported by mattruby
102
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openoffice.org (Ubuntu)
Invalid
Undecided
Matthias Klose
python-central (Debian)
Fix Released
Unknown
python-central (Ubuntu)
Fix Released
Undecided
Matthias Klose

Bug Description

Binary package hint: python-uno

On my Ubuntu/Edgy workstation, OO.o's dependency on python-uno is broken, possibly something to do with python-central:

# apt-get update
[OK]
# apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run `apt-get -f install' to correct these.
The following packages have unmet dependencies:
    python-uno: Depends: openoffice.org-core (= 2.0.4-0ubuntu2) but 2.0.4-0ubuntu3 is installed
E: Unmet dependencies. Try using -f.
# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
    python-uno
The following packages will be upgraded:
    python-uno
1 upgraded, 0 newly installed, 0 to remove and 31 not upgraded.
31 not fully installed or removed.
Need to get 0B/220kB of archives.
After unpacking 0B of additional disk space will be used.
Do you want to continue [Y/n]?
(Reading database ... 156818 files and directories currently installed.)
Preparing to replace python-uno 2.0.4-0ubuntu2 (using .../python-uno_2.0.4-0ubuntu3_i386.deb) ...
Traceback (most recent call last):
    File "/usr/bin/pycentral", line 1367, in ?
        main()
    File "/usr/bin/pycentral", line 1361, in main
        rv = action.run(global_options)
    File "/usr/bin/pycentral", line 946, in run
        pkg.remove(runtimes, remove_script_files=True)
    File "/usr/bin/pycentral", line 696, in remove
        default_runtime.remove_byte_code(self.private_file s)
AttributeError: 'NoneType' object has no attribute 'remove_byte_code'
dpkg: warning - old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
Traceback (most recent call last):
    File "/usr/bin/pycentral", line 1367, in ?
        main()
    File "/usr/bin/pycentral", line 1361, in main
        rv = action.run(global_options)
    File "/usr/bin/pycentral", line 946, in run
        pkg.remove(runtimes, remove_script_files=True)
    File "/usr/bin/pycentral", line 696, in remove
        default_runtime.remove_byte_code(self.private_file s)
AttributeError: 'NoneType' object has no attribute 'remove_byte_code'
dpkg: error processing /var/cache/apt/archives/python-uno_2.0.4-0ubuntu3_ i386.deb (--unpack):
  subprocess new pre-removal script returned error exit status 1
Errors were encountered while processing: /var/cache/apt/archives/python-uno_2.0.4-0ubuntu3_ i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Revision history for this message
Kevin Kubasik (kkubasik) wrote :

Assigning this to the openoffice.org scribblers.

Changed in openoffice.org:
assignee: nobody → openoffice-pkgs
Revision history for this message
Matthias Klose (doko) wrote :

which version of python-central is installed? dpkg -l python-central

Changed in openoffice.org:
status: Unconfirmed → Needs Info
Revision history for this message
mattruby (email-mattruby) wrote : Re: [Bug 75557] Re: instal python-uno broken: /usr/bin/pycentral::default_runtime.remove_byte_code() : 'NoneType' object

python-central 0.5.10ubuntu1

On Wed, 2006-12-13 at 10:13 +0000, Matthias Klose wrote:
> which version of python-central is installed? dpkg -l python-central
>
>
> ** Changed in: openoffice.org (Ubuntu)
> Status: Unconfirmed => Needs Info
>
--

(C) Matthew Rubenstein

Revision history for this message
Kazade (kazade) wrote :

Im having the same problem on Kubuntu Edgy, I just updated OpenOffice. This is the result of dpkg -l python-central.

+++-===================-===================-======================================================
ii python-central 0.5.6ubuntu2 register and build utility for Python packages

Revision history for this message
Kazade (kazade) wrote :

Oh and if it helps at all here is my traceback after running: sudo apt-get -f install

Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  python-uno
The following packages will be upgraded:
  python-uno
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/220kB of archives.
After unpacking 0B of additional disk space will be used.
Do you want to continue [Y/n]? Y
(Reading database ... 122531 files and directories currently installed.)
Preparing to replace python-uno 2.0.4-0ubuntu3 (using .../python-uno_2.0.4-0ubuntu4_i386.deb) ...
Traceback (most recent call last):
  File "/usr/bin/pycentral", line 1348, in ?
    main()
  File "/usr/bin/pycentral", line 1342, in main
    rv = action.run(global_options)
  File "/usr/bin/pycentral", line 935, in run
    pkg.remove(runtimes, remove_script_files=True)
  File "/usr/bin/pycentral", line 693, in remove
    default_runtime.remove_byte_code(self.private_files)
AttributeError: 'NoneType' object has no attribute 'remove_byte_code'
dpkg: warning - old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
Traceback (most recent call last):
  File "/usr/bin/pycentral", line 1348, in ?
    main()
  File "/usr/bin/pycentral", line 1342, in main
    rv = action.run(global_options)
  File "/usr/bin/pycentral", line 935, in run
    pkg.remove(runtimes, remove_script_files=True)
  File "/usr/bin/pycentral", line 693, in remove
    default_runtime.remove_byte_code(self.private_files)
AttributeError: 'NoneType' object has no attribute 'remove_byte_code'
dpkg: error processing /var/cache/apt/archives/python-uno_2.0.4-0ubuntu4_i386.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/python-uno_2.0.4-0ubuntu4_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Revision history for this message
Kazade (kazade) wrote :

OK i did a bit of debugging and I think the reason this error is occuring is because the following if statement doesnt get entered:

            if version == default_version:
                default_runtime = rt

This is on line 218 of pycentral on my set up this is because version == '2.4' whereas default_version == '24'.

I hope that helps someone, sorry I dont have time to come up with a proper bug fix.

Revision history for this message
Kazade (kazade) wrote :

Replacing the if with:

            if version == default_version or version.replace('.', '') == default_version:
                default_runtime = rt

worked for me.

Revision history for this message
khperkins (khperkins) wrote :

Getting the same problem.
(Reading database ... 164529 files and directories currently installed.)
Preparing to replace python-uno 2.0.4-0ubuntu2 (using .../python-uno_2.0.4-0ubuntu4_i386.deb) ...
Traceback (most recent call last):
  File "/usr/bin/pycentral", line 1348, in ?
    main()
  File "/usr/bin/pycentral", line 1342, in main
    rv = action.run(global_options)
  File "/usr/bin/pycentral", line 935, in run
    pkg.remove(runtimes, remove_script_files=True)
  File "/usr/bin/pycentral", line 693, in remove
    default_runtime.remove_byte_code(self.private_files)
AttributeError: 'NoneType' object has no attribute 'remove_byte_code'
dpkg: warning - old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
Traceback (most recent call last):
  File "/usr/bin/pycentral", line 1348, in ?
    main()
  File "/usr/bin/pycentral", line 1342, in main
    rv = action.run(global_options)
  File "/usr/bin/pycentral", line 935, in run
    pkg.remove(runtimes, remove_script_files=True)
  File "/usr/bin/pycentral", line 693, in remove
    default_runtime.remove_byte_code(self.private_files)
AttributeError: 'NoneType' object has no attribute 'remove_byte_code'
dpkg: error processing /var/cache/apt/archives/python-uno_2.0.4-0ubuntu4_i386.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/python-uno_2.0.4-0ubuntu4_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
(Using apt-get upgrade/instal/-f install etc.
Also seems that:
python-uno: Depends: openoffice.org-core (= 2.0.4-0ubuntu2) but 2.0.4-0ubuntu4 is installed
there's a dependency problem in the python-uno package. Maybe that's the cause of the errors?

Revision history for this message
khperkins (khperkins) wrote :

Whoops
on Edgy
and
python-central 0.5.6ubuntu2
the "fix" didn't work for me either.

Revision history for this message
khperkins (khperkins) wrote :

From lamego in this thread ( http://ubuntuforums.org/showthread.php?t=322857 )on the Ubuntu forums:

sudo rm /var/lib/dpkg/info/python-uno.prerm
sudo apt-get remove python-uno
sudo apt-get install python-uno

Revision history for this message
mattruby (email-mattruby) wrote :

 That didn't change anything for me. But it inspired me to
edit /usr/bin/pycentral:696 , which failed with default_runtime is
"NoneType":

# diff /usr/bin/pycentral.bug /usr/bin/pycentral
696c696,700
< default_runtime.remove_byte_code(self.private_files)
---
>
self.default_runtime.remove_byte_code(self.private_files)
>
> #default_runtime.remove_byte_code(self.private_files)
> # fails: default_runtime is "NoneType"

Now (apt-get -f install) completes the openoffice.org (and the rest of
the held back packages) OK. Then (apt-get upgrade) seems to do a lot of
that again. FWIW, any language that points at separate objects with the
names "self.<object>" and "<object>" has serious design defects.
Disambiguation should not create ambiguity. And how come it failed only
on a few installations, like mine? Don't get me started (too late)...

On Thu, 2006-12-21 at 10:13 +0000, Kazade wrote:
> Replacing the if with:
>
> if version == default_version or version.replace('.', '') == default_version:
> default_runtime = rt
>
> worked for me.
>
--

(C) Matthew Rubenstein

Revision history for this message
Mattia Belletti (redglow) wrote :

I'm looking at debian version of this, but I think the same. The problem for me was a not-so-robust way of getting the default version of python from pyversions.py:

_default_version = None
def default_version(version_only=False):
    global _default_version
    if not _default_version:
        _default_version = link = os.readlink('/usr/bin/python')
    if version_only:
        return _default_version[6:]
    else:
        return _default_version

if the /usr/bin/python symlink is the usual stuff like 'python2.4', everything's fine, but if it's something longer like '/usr/bin/python2.4' it breaks. So, it's enough to change the "return _default_version[6:]" onto something more flexible like:

        return re.match(r'.*(\d+\.\d+)', _default_version).group(1)

In attachment, a patch which does exactly this.

Revision history for this message
Manuel Martín Salvador (draxus) wrote :
Revision history for this message
Mattia Belletti (redglow) wrote :

Oh, fine! I hope this definitely solve the bug!

Revision history for this message
Matthias Klose (doko) wrote :

why in the first place did you change the /usr/bin/python symlink?

Changed in openoffice.org:
assignee: openoffice-pkgs → doko
status: Needs Info → In Progress
Revision history for this message
Mattia Belletti (redglow) wrote :

Obviously, because I wanted to experiment with python pointing to a different version (2.5, in my case). By the way, how come python isn't managed by the alternatives mechanism?
Ok, I know: if I do something by hand, then I'm on my own. But, anyway, the program should raise an adeguate exception, rather than this one (something that say "python symlink is wrong: it should be something like 'pythonX.Y'").

Revision history for this message
Nelson A. de Oliveira (naoliv) wrote :

Argh... sorry for the click on this button :-/
It doesn't affect OpenOffice.
Sorry

Changed in python-central:
status: Unknown → Needs Info
Revision history for this message
Matthias Klose (doko) wrote : Re: [Bug 75557] Re: instal python-uno broken: /usr/bin/pycentral::default_runtime.remove_byte_code() : 'NoneType' object

RedGlow schrieb:
> Obviously, because I wanted to experiment with python pointing to a different version (2.5, in my case).

then don't mess with /usr, but do changes in your home or /usr/local.

> By the way, how come python isn't managed by the alternatives mechanism?

it is not an alternative and will break dependencies.

> Ok, I know: if I do something by hand, then I'm on my own. But, anyway, the program should raise an adeguate exception, rather than this one (something that say "python symlink is wrong: it should be something like 'pythonX.Y'").

no anyway. we cannot anticipate your doing.

Revision history for this message
Kazade (kazade) wrote :

> then don't mess with /usr, but do changes in your home or /usr/local.

This bug has affected quite a few people though. I think it affected me because i installed python 2.5 and I had to change the symlinks so that "python" would run 2.4, either way RedGlow's regex fix is a far more robust way of getting the default python version and IMO there is no reason not to put it in.

Revision history for this message
Matthias Klose (doko) wrote :

Kazade schrieb:
>> then don't mess with /usr, but do changes in your home or /usr/local.
>
> This bug has affected quite a few people though. I think it affected me
> because i installed python 2.5 and I had to change the symlinks so that
> "python" would run 2.4, either way RedGlow's regex fix is a far more
> robust way of getting the default python version and IMO there is no
> reason not to put it in.

it's not a fix; it hides the modification of the default python version, getting
errors later on. I'll add a check if the user did mess around with the python
symlink and abort with an error.

Revision history for this message
Mattia Belletti (redglow) wrote :

> it's not a fix; it hides the modification of the default python version, getting
> errors later on. I'll add a check if the user did mess around with the python
> symlink and abort with an error.

Which is a good solution, since python's version is supposed to be kept fixed, as you said. I changed the code without thinking about this. In fact, I changed the /usr/bin/python symlink and forget about it, so I didn't even remember it was a modification of mine, and not a package action.
But, please, try to be a little less rude upon confrontation. It is no problem to me, as I understand what you intend, but I think everybody here is just trying to get around some problem, not offending you, since you are surely much more prepared and knowledgeable about such matters than us.

Changed in python-central:
status: Needs Info → Fix Released
Revision history for this message
Matthias Klose (doko) wrote :

an updated package can be found at http://people.ubuntu.com/~doko/tmp/python-central_0.5.12ubuntu4_all.deb
please check if/that it catches the issues with the modified python symlink.

Revision history for this message
Matthias Klose (doko) wrote :

fixed in python-central_0.5.12ubuntu4

Changed in python-central:
status: In Progress → Fix Released
Revision history for this message
Matthias Klose (doko) wrote :

rejecting the OOo task.

Changed in openoffice.org:
assignee: nobody → doko
status: Unconfirmed → Rejected
Revision history for this message
mattruby (email-mattruby) wrote :

Something is really broken in my python installation. I'm trying to run update-manager, but it fails:

# update-manager
Traceback (most recent call last):
  File "/usr/bin/update-manager", line 32, in <module>
    from UpdateManager.UpdateManager import UpdateManager
ImportError: No module named UpdateManager.UpdateManager

That's with /usr/bin/python pointing at /usr/bin/python2.5 . If I change the symlink to point at /usr/bin/python2.4 , I get a different error:

# update-manager
Traceback (most recent call last):
  File "/usr/bin/update-manager", line 28, in ?
    import gtk
ImportError: No module named gtk

I have already run apt-get --reinstall install python2.4 python2.5 python-gtk2 python-glade2 update-manager .

Do I have to uninstall python2.4 and python2.5, and everything on which they depend (most of my GNOME, etc), then reinstall everything? How am I supposed to keep track of what to reinstall? This is a mess.

Revision history for this message
Alexandr Rudenko (hinode-mikado) wrote :

The same problem.
1) The release of Ubuntu:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu hardy (development branch)"
2) The version of the package:
python-apt 0.7.4ubuntu4
3) What happened :
~$ sudo apt-get upgrade

(Чтение базы данных... на данный момент установлено 189203 файлов и каталогов.)
Подготовка к замене пакета python-apt 0.7.4ubuntu4 (используется файл .../python-apt_0.7.4ubuntu5_i386.deb)...
Traceback (most recent call last):
  File "/usr/bin/pycentral", line 1593, in <module>
    main()
  File "/usr/bin/pycentral", line 1587, in main
    rv = action.run(global_options)
  File "/usr/bin/pycentral", line 1075, in run
    requested = pyversions.requested_versions_for_runtime(version_field, version_only=True)
  File "/usr/share/pycentral-data/pyversions.py", line 172, in requested_versions_for_runtime
    vinfo = parse_versions(vstring)
  File "/usr/share/pycentral-data/pyversions.py", line 58, in parse_versions
    raise ValueError, 'error parsing Python-Version attribute'
ValueError: error parsing Python-Version attribute
dpkg: не удалось обработать параметр /var/cache/apt/archives/python-apt_0.7.4ubuntu5_i386.deb (--unpack):
 подпроцесс pre-installation script возвратил код ошибки 1
При обработке следующих пакетов произошли ошибки:
 /var/cache/apt/archives/python-apt_0.7.4ubuntu5_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Revision history for this message
David Racine (bass-dr) wrote :

I found a way to solve my problem, see Bug #371017 it solves the problem for those who manually symlinked their python and cannot turn back

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.