Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: virt-manage, ImportError: No module named 'gi'

  1. #1

    Question virt-manage, ImportError: No module named 'gi'

    Hello,

    the virt-manger doesn't run, it ends with error:

    Code:
    Traceback (most recent call last):
      File "/usr/share/virt-manager/virt-manager", line 16, in <module>
        import gi
    ImportError: No module named 'gi'
    Do you know how to fix it?

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    9,885
    Blog Entries
    1

    Default Re: virt-manage, ImportError: No module named 'gi'

    Just guessing,
    You might try a force re-install as follows (especially if you've attempted any manual re-configuration. Be sure to back up your configurations if you did do something manually)
    Code:
    zypper in -f libvirt
    And, although not likely required or directly related to your issue it's probably a good time to update your system as well
    Code:
    zypper up
    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #3

    Default Re: virt-manage, ImportError: No module named 'gi'

    Quote Originally Posted by tsu2 View Post
    Just guessing,
    You might try a force re-install as follows (especially if you've attempted any manual re-configuration. Be sure to back up your configurations if you did do something manually)
    Code:
    zypper in -f libvirt
    And, although not likely required or directly related to your issue it's probably a good time to update your system as well
    Code:
    zypper up
    TSU
    It didn't work.

  4. #4
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    9,885
    Blog Entries
    1

    Default Re: virt-manage, ImportError: No module named 'gi'

    Open up that file and inspect line 16 to see if it really does say it's trying to import a module named 'gi"

    If you're not sure what you're looking at, post your entire file either here or in a pastebin for inspection.
    I'm not in front of a machine where I can compare to a known good file, but trying to make sense of, and verifying the error is a reasonable step.

    Edit - Although I'm not in front of a machine, I found the file online to verify the command is correct
    https://github.com/virt-manager/virt...r/virt-manager
    According to the above, you should check your LibvirtGlib for its existence and version

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  5. #5

    Default Re: virt-manage, ImportError: No module named 'gi'

    Quote Originally Posted by tsu2 View Post
    Open up that file and inspect line 16 to see if it really does say it's trying to import a module named 'gi"

    If you're not sure what you're looking at, post your entire file either here or in a pastebin for inspection.
    I'm not in front of a machine where I can compare to a known good file, but trying to make sense of, and verifying the error is a reasonable step.

    Edit - Although I'm not in front of a machine, I found the file online to verify the command is correct
    https://github.com/virt-manager/virt...r/virt-manager
    According to the above, you should check your LibvirtGlib for its existence and version

    TSU
    Thats the only package which I've found:

    Code:
    sudo zypper search LibvirtGlib
    Loading repository data...
    Reading installed packages...
    
    S  | Name                        | Summary                                           | Type   
    ---+-----------------------------+---------------------------------------------------+--------
    i+ | typelib-1_0-LibvirtGLib-1_0 | GLib and GObject mapping of libvirt - gi-bindings | package
    Here is the first part of the virt-manager file:

    Code:
    !/usr/bin/env python3
    #
    # Copyright (C) 2006, 2014 Red Hat, Inc.
    # Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
    #
    # This work is licensed under the GNU GPLv2 or later.
    # See the COPYING file in the top-level directory.
    
    import argparse
    import logging
    import os
    import signal
    import sys
    import traceback
    
    import gi
    gi.require_version('LibvirtGLib', '1.0')
    from gi.repository import LibvirtGLib
    
    from virtinst import util
    from virtinst import cli
    from virtcli import CLIConfig
    
    # This is massively heavy handed, but I can't figure out any way to shut
    # up the slew of gtk deprecation warnings that clog up our very useful
    # stdout --debug output. Of course we could drop use of deprecated APIs,
    # but it's a serious quantity of churn
    import warnings  # pylint: disable=wrong-import-order
    warnings.simplefilter("ignore")
    
    try:
        gi.check_version("3.14.0")
    except (ValueError, AttributeError):
        print("pygobject3 3.14.0 or later is required.")
        sys.exit(1)

  6. #6
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,089
    Blog Entries
    14

    Default Re: virt-manage, ImportError: No module named 'gi'

    Quote Originally Posted by tsu2 View Post
    And, although not likely required or directly related to your issue it's probably a good time to update your system as well
    Code:
    zypper up
    TSU
    TSU, Never use 'zypper up' on a Tumbleweed system, but use
    Code:
    zypper dup
    as per documentation.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  7. #7
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    25,454
    Blog Entries
    15

    Default Re: virt-manage, ImportError: No module named 'gi'

    Quote Originally Posted by Skeletonix View Post
    Hello,

    the virt-manger doesn't run, it ends with error:

    Code:
    Traceback (most recent call last):
      File "/usr/share/virt-manager/virt-manager", line 16, in <module>
        import gi
    ImportError: No module named 'gi'
    Do you know how to fix it?
    Hi
    An import error is python related, maybe switched to python3, so are there python gobject packages installed?

    Code:
    zypper se -i python*-gobject*
    Is the python3 version installed?

    A quick test;
    Code:
    python -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    AttributeError: 'module' object has no attribute '__spec__'
    
    Fail
    
    python2 -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    AttributeError: 'module' object has no attribute '__spec__'
    
    Fail
    
    python3 -c "import gi; print(gi.__spec__)"
    ModuleSpec(name='gi', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fd3c1bdfa20>, origin='/usr/lib64/python3.6/site-packages/gi/__init__.py', submodule_search_locations=['/usr/lib64/python3.6/site-packages/gi'])
    
    working
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  8. #8

    Default Re: virt-manage, ImportError: No module named 'gi'

    Quote Originally Posted by malcolmlewis View Post
    Hi
    An import error is python related, maybe switched to python3, so are there python gobject packages installed?

    Code:
    zypper se -i python*-gobject*
    Is the python3 version installed?

    A quick test;
    Code:
    python -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    AttributeError: 'module' object has no attribute '__spec__'
    
    Fail
    
    python2 -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    AttributeError: 'module' object has no attribute '__spec__'
    
    Fail
    
    python3 -c "import gi; print(gi.__spec__)"
    ModuleSpec(name='gi', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fd3c1bdfa20>, origin='/usr/lib64/python3.6/site-packages/gi/__init__.py', submodule_search_locations=['/usr/lib64/python3.6/site-packages/gi'])
    
    working
    I do have the gobject packages installed:

    Code:
    zypper se -i python*-gobject*
    Loading repository data...
    Reading installed packages...
    
    S  | Name                  | Summary                           | Type   
    ---+-----------------------+-----------------------------------+--------
    i+ | python-gobject2       | Python bindings for GObject       | package
    i+ | python2-gobject       | Python bindings for GObject       | package
    i+ | python2-gobject-Gdk   | Python bindings for GObject/Gdk   | package
    i+ | python2-gobject-cairo | Python bindings for GObject/Cairo | package
    i+ | python3-gobject       | Python bindings for GObject       | package
    i+ | python3-gobject-Gdk   | Python bindings for GObject/Gdk   | package
    i+ | python3-gobject-cairo | Python bindings for GObject/Cairo | package
    i+ | python3-gobject2      | Python bindings for GObject       | package
    Neither of the quick test options work:

    Code:
    python -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named 'gi'
    
    python2 -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    AttributeError: 'module' object has no attribute '__spec__'
    
    python3 -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named 'gi'

  9. #9
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    25,454
    Blog Entries
    15

    Default Re: virt-manage, ImportError: No module named 'gi'

    Quote Originally Posted by Skeletonix View Post
    I do have the gobject packages installed:

    Code:
    zypper se -i python*-gobject*
    Loading repository data...
    Reading installed packages...
    
    S  | Name                  | Summary                           | Type   
    ---+-----------------------+-----------------------------------+--------
    i+ | python-gobject2       | Python bindings for GObject       | package
    i+ | python2-gobject       | Python bindings for GObject       | package
    i+ | python2-gobject-Gdk   | Python bindings for GObject/Gdk   | package
    i+ | python2-gobject-cairo | Python bindings for GObject/Cairo | package
    i+ | python3-gobject       | Python bindings for GObject       | package
    i+ | python3-gobject-Gdk   | Python bindings for GObject/Gdk   | package
    i+ | python3-gobject-cairo | Python bindings for GObject/Cairo | package
    i+ | python3-gobject2      | Python bindings for GObject       | package
    Neither of the quick test options work:

    Code:
    python -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named 'gi'
    
    python2 -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    AttributeError: 'module' object has no attribute '__spec__'
    
    python3 -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named 'gi'
    Hi
    Can you try to uninstall python3-gobject2, or does it create issues? If not then test again
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  10. #10
    Join Date
    Sep 2012
    Posts
    4,782

    Default Re: virt-manage, ImportError: No module named 'gi'

    Quote Originally Posted by malcolmlewis View Post
    Code:
    python2 -c "import gi; print(gi.__spec__)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    AttributeError: 'module' object has no attribute '__spec__'
    
    Fail
    Code:
    bor@10:~> python2 -c 'import gi; print (gi.__file__)'
    /usr/lib64/python2.7/site-packages/gi/__init__.pyc
    bor@10:~>

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •