[SRU] Error starting Virtual Machine Manager: No module named version

Bug #680627 reported by Rolf Leggewie
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
virtinst (Ubuntu)
Invalid
High
Unassigned
Lucid
Fix Released
Undecided
Marc Deslauriers

Bug Description

Binary package hint: virt-manager

One of my lucid machines does not allow me to run virt-manager. A GUI window opens with the following text:

Error starting Virtual Machine Manager: No module named version

virt-manager requires the python-virtinst library version 0.500.1 or greater. This can be downloaded at:

http://virt-manager.org/download.html

Under Details there is a python traceback.

Traceback (most recent call last):
  File "/usr/share/virt-manager/virt-manager.py", line 410, in <module>
    main()
  File "/usr/share/virt-manager/virt-manager.py", line 317, in main
    raise RuntimeError(str(e) + "\n\n" + msg)
RuntimeError: No module named version

virt-manager requires the python-virtinst library version 0.500.1 or greater. This can be downloaded at:

http://virt-manager.org/download.html

python-virtinst package is installed at version 0.500.1-2ubuntu6.1.

Revision history for this message
Matthew McCarty (m-tthew-mcc-rty) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. This particular bug has already been reported and is a duplicate of bug 203852, so it is being marked as such. Please look at the other bug report to see if there is any missing information that you can provide, or to see if there is a workaround for the bug. Additionally, any further discussion regarding the bug should occur in the other report. Feel free to continue to report any other bugs you may find.

Revision history for this message
Matthew McCarty (m-tthew-mcc-rty) wrote :

I believe I made a mistake by making this bug as a duplicate of https://bugs.launchpad.net/bugs/203852.

I marked this bug as a duplicate when I read this comment (https://bugs.launchpad.net/ubuntu/+source/dbus-python/+bug/203852/comments/1) but now I believe the above comment was posting in error..

Sorry, Matthew

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Do you have the virtinst package installed? If so, could you try reinstalling it with the following command:
apt-get install --reinstall virtinst

Changed in virt-manager (Ubuntu):
status: New → Incomplete
Revision history for this message
Rolf Leggewie (r0lf) wrote :

Reinstalling the virt-inst package made no difference.

I am running the virt-manager program remotely, forwarded over ssh if that makes any difference.

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

You mean you forwarding X through SSH, or you're using a remote connection in virt-manager?

Revision history for this message
Rolf Leggewie (r0lf) wrote :

I am forwarding X over ssh ("ssh -X $remotecomputer")

Revision history for this message
Patrick Spinler (spinler-patrick) wrote :

FWIW, the error is being thrown here:

/usr/share/virt-manager/virt-manager.py line 306:

    # Make sure we have a sufficiently new virtinst version, since we are
    # very closely tied to the lib
    msg = ("virt-manager requires the python-virtinst library version " +
            virtinst_str + " or greater. This can be downloaded at:"
            "\n\nhttp://virt-manager.org/download.html")
    try:
        import virtinst
        ignore = virtinst.__version__
        ignore = virtinst.__version_info__
    except Exception, e:
        logging.exception("Error import virtinst")
        raise RuntimeError(str(e) + "\n\n" + msg)

virtinst_str is defined at line 42 of that same file as:

virtinst_str = "0.500.1"
virtinst_version = tuple([ int(num) for num in virtinst_str.split('.')])

note that I do have python-virtinst installed at the requisite level, at least according to the package database:

pjs11@patslinux01 ~ $ dpkg-query --list virtinst python-virtinst
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-===============================-===============================-==============================================================================
ii python-virtinst 0.500.1-2ubuntu6.1 Programs to create and clone virtual machines (transitional package)
ii virtinst 0.500.1-2ubuntu6.1 Programs to create and clone virtual machines

However, a basic "import virtinst" test fails:

pjs11@patslinux01 ~ $ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import virtinst
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/dist-packages/virtinst/__init__.py", line 27, in <module>
    from version import __version__
ImportError: No module named version

Unfortunately, my ability to investigate further is hampered by my more or less complete lack of python-fu. Can anyone suggest how I can investigate this further?

Thanks!
-- Pat

Revision history for this message
Patrick Spinler (spinler-patrick) wrote :

Just a stupid question, but is the python-virtinst package supposed to be empty excepting documentation?

pjs11@patslinux01 ~ $ dpkg-query --listfiles python-virtinst
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/python-virtinst
/usr/share/doc/python-virtinst/copyright
/usr/share/doc/python-virtinst/README
/usr/share/doc/python-virtinst/AUTHORS
/usr/share/doc/python-virtinst/changelog.gz
/usr/share/doc/python-virtinst/NEWS.gz
/usr/share/doc/python-virtinst/changelog.Debian.gz

Revision history for this message
Patrick Spinler (spinler-patrick) wrote :

Sorry for the stupid question, answered it myself: yes, it is. The package containing all the useful stuff in Lucid is just 'virtinst'. :-(

Revision history for this message
Patrick Spinler (spinler-patrick) wrote :

This appears to be the root cause:

pjs11@patslinux01 ~ $ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import version
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named version
>>>

Here's where I hit my python-fu limits again, Isn't "version" supposed to be part of the core language? Or is there a package that needs to be installed for this?

Help, please!

Thanks,
-- Pat

Revision history for this message
Patrick Spinler (spinler-patrick) wrote :

Answered my own question again -- "version.py" is a file being shipped in the virtinst package, under /usr/share/pyshared/virtinst, and it contains the single variable "__version__'.

So, for some reason, the import in virtinst/__init__.py expects to find virtinst/version.py, but can't.

Apologies for the flood of notes, many with stupid questions I'm answering myself. :-(

-- Pat

Revision history for this message
Patrick Spinler (spinler-patrick) wrote :

Ah ha! I think I have nailed the issue, at least for me: it's a combination of a python module import path error, and left over debris of an earlier virtinst: take a look:

First, notice that my python doesn't even have a module path that includes /usr/share/pyshared:

pjs11@patslinux01 ~ $ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/Numeric', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']
>>>

Next, notice that I have multiple instances of the python virtinst package, and one is considerably older:

pjs11@patslinux01 ~ $ ls -idl /usr/share/pyshared/virtinst* /usr/lib/python2.6/dist-packages/virtinst*
438053 drwxr-xr-x 2 root root 4096 2011-02-18 11:45 /usr/lib/python2.6/dist-packages/virtinst
438054 lrwxrwxrwx 1 root root 45 2010-04-08 16:38 /usr/lib/python2.6/dist-packages/virtinst-0.300.2.egg-info -> /usr/share/pyshared/virtinst-0.300.2.egg-info
398964 drwxr-xr-x 2 root root 4096 2011-02-18 11:51 /usr/share/pyshared/virtinst
621357 -rw-r--r-- 1 root root 275 2010-10-12 15:32 /usr/share/pyshared/virtinst-0.500.1-py2.6.egg-info

And notice that the older one is not owned by any package:

pjs11@patslinux01 ~ $ dpkg-query --search /usr/lib/python2.6/dist-packages/virtinst*
dpkg: /usr/lib/python2.6/dist-packages/virtinst not found.
dpkg: /usr/lib/python2.6/dist-packages/virtinst-0.300.2.egg-info not found.

Finally, notice that if I make use of the current directory import path in my sys.path (the null string ""), by cd'ing to /usr/share/pyshared, then "import virtinst" works:

pjs11@patslinux01 ~ $ cd /usr/share/pyshared
pjs11@patslinux01 pyshared $ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import virtinst
>>>

So, my fix is to first, delete the old, leftover and unowned package, and second fix my import path (and btw -- why does the sys import path even contain the current directory -- isn't that kinda a bad security policy?)

I know how to do the first, I just delete the unowned files, but where do I adjust the second, the import path?

Thanks,
-- Pat

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

When you did the "import virtinst" in python, it seemed to have found this file:

/usr/lib/python2.6/dist-packages/virtinst/__init__.py

That file is not part of lucid's virtinst package...it should be /usr/share/pyshared/virtinst/__init__.py and then symlinked to /usr/lib/pymodules/python2.6/virtinst

Did you manually install virtinst at some point?
Do you have __init__.py in /usr/share/pyshared/virtinst and symlinked to /usr/lib/pymodules/python2.6/virtinst ?

How about doing a "sudo mv /usr/lib/python2.6/dist-packages/virtinst /usr/lib/python2.6/dist-packages/virtinst.old" and trying again?

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

You shouldn't add /usr/share/pyshared to your import path...files in there are supposed to get symlinked to /usr/lib/pymodules/python2.6...

Simply renaming or deleting the old files should be enough.

Revision history for this message
Patrick Spinler (spinler-patrick) wrote :

Indeed, as you suggest, moving away the old files was sufficient. I can now successfully run virt-manager.

I don't recall ever doing a manual install of virtinst on this machine , so I'm unclear where the old version came from, however, that was the issue.

Thanks very much! Hopefully this also helps the original poster.

-- Pat

Revision history for this message
Rolf Leggewie (r0lf) wrote :

Patrick, thank you for your digging into the issue. In fact, it looks like you had the same issue as me. My non-working computer has the same files as you reported. /usr/lib/python2.6/dist-packages/virtinst-0.300.2.egg-info is a broken symlink to /usr/share/pyshared/virtinst-0.300.2.egg-info. I guess I know how to fix the problem locally now, thank you very much. I'd like to see a proper fix released to lucid, of course. But I think we still don't know where this file came from, do we?

Setting to confirmed.

Changed in virt-manager (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Rolf Leggewie (r0lf) wrote :
Changed in virt-manager (Ubuntu):
importance: Undecided → High
status: Confirmed → Triaged
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Did both of you upgrade from Hardy to Lucid?

Revision history for this message
Rolf Leggewie (r0lf) wrote :

yes, at least I did the straight upgrade between LTS hard to LTS lucid. Must have been about half a year ago.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

"sudo rm /usr/lib/python2.6/dist-packages/virtinst-0.300.2.egg-info /usr/lib/python2.6/dist-packages/virtinst/DistroManager.py*" did not fix the problem here. Anything else I need to do?

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Try removing the whole /usr/lib/python2.6/dist-packages/virtinst directory.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

Yes, that finally seems to do the trick. Thanks, Marc.

Can we see a fixed package to deal with this in lucid?

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Yes, I will try and reproduce the issue, and will release a fix. Thanks!

summary: - Error starting Virtual Machine Manager: No module named version
+ [SRU] Error starting Virtual Machine Manager: No module named version
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

SRU request:

Impact: Users upgrading from Hardy to Lucid have a broken virtinst installation because the transition from python-central to python-support leaves obsolete files behind in /usr/lib/python2.6/dist-packages/virtinst.

This update fixes the issue by adding a python-virtinst.preinst file that uses pycentral to remove the obsolete files. An added complexity is the fact that python-virtinst is now a transitional package, so extra logic is added to specify the new package name to pycentral.

See attached debdiff.

How to reproduce:

test case #1:
- Install hardy
- Install virt-manager
- Upgrade to lucid
- Try running virt-manager
- Install upgraded package in -proposed
- Try running virt-manager

test case #2:
- Install hardy
- Install virt-manager
- Install updated package in -proposed
- Upgrade to lucid
- Try running virt-manager

Changed in virt-manager (Ubuntu Lucid):
status: New → Confirmed
affects: virt-manager (Ubuntu) → virtinst (Ubuntu)
Changed in virtinst (Ubuntu Lucid):
assignee: nobody → Marc Deslauriers (mdeslaur)
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Maverick and Natty don't need this, as the only supported upgrade path from Hardy and Karmic is Lucid.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

Marc, thank you for your work. Two questions.

One, you say this issue came about by switching from python-central to python-support. Is it possible that other packages are affected as well? Should this be fixed in python-support?

Two, you correctly remark that the only upgrade patch is via Lucid. From this you conclude (as I did initially) that Maverick and Natty are unaffected. But what about users that have already done karmic-lucid upgrade for example and moved on to maverick or even natty in the meantime? The workaround is easy enough to find in this ticket and I'm not sure the number of affected users is large enough to warrant a special solution for this. I'm merely pointing out the possibilities that there are users on maverick and natty that are affected by this. I leave it up to you to decide what to do.

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Yes, other packages could be affected, although this was the case in Debian also, so most packages should already have the required goo to handle this gracefully.

I agree if someone went from hardy or karmic to lucid and is now on maverick or natty they would still have the broken symlinks in place. As you said, I'm not sure there's enough users that have done that and have been living with a broken virtinst for that long that it would be worthwhile to fix it in more recent releases.

Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Accepted virtinst into lucid-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in virtinst (Ubuntu):
status: Triaged → Invalid
Changed in virtinst (Ubuntu Lucid):
status: Confirmed → Fix Committed
tags: added: verification-needed
Revision history for this message
Rolf Leggewie (r0lf) wrote :

the package in -proposed fixes the problem. Thank you. Please release to -updates at your earliest convenience.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package virtinst - 0.500.1-2ubuntu6.2

---------------
virtinst (0.500.1-2ubuntu6.2) lucid-proposed; urgency=low

  * debian/python-virtinst.preinst: use pycentral to clean up after old
    python-virtinst package so upgrades from hardy don't break.
    (LP: #680627)
 -- Marc Deslauriers <email address hidden> Sat, 26 Feb 2011 15:48:40 -0500

Changed in virtinst (Ubuntu Lucid):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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