Bug 1372927

Summary: ImportError: No module named libvirt although it's there
Product: [Community] Virtualization Tools Reporter: jean-christophe manciot <actionmystique>
Component: virt-managerAssignee: Cole Robinson <crobinso>
Status: CLOSED DEFERRED QA Contact:
Severity: urgent Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: actionmystique, berrange, crobinso, gscrivan, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-29 17:44:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description jean-christophe manciot 2016-09-03 21:38:32 UTC
Description of problem:
----------------------
virt-manager complains about libvirt not being there although:
1) libvirt 2.2.0 is installed & working fine
    libvirtd --version
    libvirtd (libvirt) 2.2.0

    systemctl status libvirt-bin
● libvirt-bin.service - Virtualization daemon
   Loaded: loaded (/lib/systemd/system/libvirt-bin.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2016-09-03 23:25:47 CEST; 10min ago
     Docs: man:libvirtd(8)
           http://libvirt.org
 Main PID: 9944 (libvirtd)
    Tasks: 32
   Memory: 36.6M
      CPU: 5.601s
   CGroup: /system.slice/libvirt-bin.service
           ├─6351 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/virtual-router.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
...
           └─9944 /usr/sbin/libvirtd

2) python-libvirt 2.2.0 is installed

Version-Release number of selected component (if applicable):
------------------------------------------------------------
Same behavior with both commits:
- virt-manager 1.4.0
- virt-manager c859d3942865007781c2974e7ed1407d6cb27ce3

How reproducible:
----------------
Compile from git sources:
- libvirt 2.2.0
- python-libvirt 2.2.0
- virt-manager 1.4.0 or c859d3942865007781c2974e7ed1407d6cb27ce3
- launch virt-manager

Actual results:
--------------
virt-manager
Traceback (most recent call last):
  File "/usr/share/virt-manager/virt-manager", line 33, in <module>
    from virtinst import util as util
  File "/usr/share/virt-manager/virtinst/__init__.py", line 39, in <module>
    from . import util
  File "/usr/share/virt-manager/virtinst/util.py", line 27, in <module>
    import libvirt
ImportError: No module named libvirt

Additional info:
---------------
Ubuntu 16.04 4.4.0-36

Comment 1 jean-christophe manciot 2016-09-03 21:55:00 UTC
No such issue with:
------------------
- libvirt v2.2.0-rc1
- python-libvirt v2.1.0
- virt-manager v1.4.0 or c859d3942865007781c2974e7ed1407d6cb27ce3

Comment 2 Cole Robinson 2016-09-08 14:20:28 UTC
What does this report: python -c 'import libvirt'

Can you check the install output of libvirt-python 2.2.0 vs 2.1.0 and see if anything is missing?

Comment 3 jean-christophe manciot 2016-09-09 07:19:01 UTC
python -c 'import libvirt'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named libvirt

although the following packages are installed:
- libvirt 2.2.0
- libvirt-python 2.2.0

Nothing special about their installation.

Comment 4 jean-christophe manciot 2016-09-09 07:26:30 UTC
There is no error message with "python -c 'import libvirt'" with:
- libvirt commit 67af358 on 08/26
- libvirt-python 2.1.0

Comment 5 jean-christophe manciot 2016-10-06 13:31:45 UTC
The issue is still there with:
- libvirt 2.3.0
- libvirt-python 2.3.0
- virt-manager latest commit 561f5cd3e68fa3f1fb6745463a5c1a486171d8c9 2016-09-08

Comment 6 jean-christophe manciot 2016-10-07 00:03:59 UTC
It seems that building and installing virt-manager & libvirt-python with --prefix=/usr have some weird and obscure side-effects.
Removing "--prefix=/usr" hides the issue of this thread, but at least virt-manager 1.4.0 is functional again with libvirt & libvirt-python 2.3.0.

Comment 7 jean-christophe manciot 2016-10-07 09:14:36 UTC
Although testing virt-manager (when built without --prefix) shows an error which does not appear during execution:
--------
Testing
--------
python setup.py test
running test
Traceback (most recent call last):
  File "setup.py", line 679, in <module>
    distclass=VMMDistribution,
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 520, in run
    TestBaseCommand.run(self)
  File "setup.py", line 447, in run
    tests = unittest.TestLoader().loadTestsFromNames(self._testfiles)
  File "/usr/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/home/actionmystique/Program-Files/Ubuntu/Virt-manager/git-virt-manager/tests/capabilities.py", line 28, in <module>
    conn = utils.open_testdriver()
  File "/home/actionmystique/Program-Files/Ubuntu/Virt-manager/git-virt-manager/tests/utils.py", line 130, in open_testdriver
    return openconn(uri_test)
  File "/home/actionmystique/Program-Files/Ubuntu/Virt-manager/git-virt-manager/tests/utils.py", line 85, in openconn
    conn = virtinst.cli.getConnection(uri)
  File "/home/actionmystique/Program-Files/Ubuntu/Virt-manager/git-virt-manager/virtinst/cli.py", line 270, in getConnection
    conn.open(_do_creds_authname)
  File "/home/actionmystique/Program-Files/Ubuntu/Virt-manager/git-virt-manager/virtinst/connection.py", line 148, in open
    open_flags)
  File "/usr/local/lib/python2.7/dist-packages/libvirt.py", line 105, in openAuth
    if ret is None:raise libvirtError('virConnectOpenAuth() failed')
libvirt.libvirtError: unsupported configuration: cannot add redirected USB device: USB is disabled for this domain

Comment 8 Cole Robinson 2017-03-29 17:44:31 UTC
Given this is old I assume it was figured out