enkore / i3pystatus

A complete replacement for i3status
https://i3pystatus.readthedocs.io/
MIT License
445 stars 189 forks source link

AttributeError: module 'gi' has no attribute 'require_version' #314

Open ghost opened 8 years ago

ghost commented 8 years ago

Arch x86_64 Python: 3.5.1 i3 version 4.11

Error: status_command process exited unexpectedly (exit 1)

status.py

# -*- coding: utf-8 -*-

import subprocess

from i3pystatus import Status

status = Status(standalone=True)

status.register("shell",
    command="hostname")

status.register("clock")

status.register("battery",
    format="{status} {remaining}")

status.register("pulseaudio",
    format="V: {volume}")

status.register("backlight",
    format="B: {percentage}",
    backlight="intel_backlight",
    on_rightclick="lighter",
    on_leftclick="darker",
    interval=1)

"""
status.register("disk",
    format="{avail}GB free",
    critical_limit=99,
    round_size=None,
    path="/")

status.register("mem",
    format="{used_mem}MB used",
    alert_percentage=88,
    warn_percentage=50,
    round_size=None,
    interval=1)

status.register("cpu_usage",
    format="{usage_cpu}%",
    interval=1)
"""

status.register("network",
   format_down="E: down",
   format_up="E: {v4}",
   interface="enp0s25",
   interval=1)

status.register("network",
    format_down="W: down",
    format_up="W: {v4}",
    interface="wlp4s0",
    interval=1)

status.run()

on python3 ~/.i3/status.py

Traceback (most recent call last):
  File ".i3/status.py", line 16, in <module>
    format="{status} {remaining}")
  File "/usr/lib/python3.5/site-packages/i3pystatus/core/__init__.py", line 78, in register
    return self.modules.append(module, *args, **kwargs)
  File "/usr/lib/python3.5/site-packages/i3pystatus/core/util.py", line 71, in append
    module, *args, **kwargs)
  File "/usr/lib/python3.5/site-packages/i3pystatus/core/imputil.py", line 47, in instanciate_class_from_module
    return self.instanciate_class_from_module(self.get_module(module), *args, **kwargs)
  File "/usr/lib/python3.5/site-packages/i3pystatus/core/imputil.py", line 41, in get_module
    return import_module("i3pystatus.{mod}".format(mod=module))
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/usr/lib/python3.5/site-packages/i3pystatus/battery.py", line 7, in <module>
    from i3pystatus.core.desktop import DesktopNotification
  File "/usr/lib/python3.5/site-packages/i3pystatus/core/desktop.py", line 34, in <module>
    gi.require_version('Notify', '0.7')
AttributeError: module 'gi' has no attribute 'require_version'
ghost commented 8 years ago

installed python-gobject, works now :smirk_cat: can you put it in the readme?

whitelynx commented 8 years ago

Actually, could AttributeError be added to the exceptions caught by i3pystatus/core/desktop.py line 36? It already catches ImportError and ValueError, which would indicate that the necessary library (python-gobject) is not installed... and in this case, it just skips the rest of the code in that module.

AttributeError here means that some package has probably installed something in the /usr/lib/python3.5/site-packages/gi/overrides/ directory (in my case, libgexiv2 did this) but you don't have python-gobject installed. This has the effect that Python sees the gi package as existing (so you won't get an ImportError), but having nothing in it. Since it still boils down to python-gobject not being installed, could we get the same behavior in this case?

cl-parsons commented 5 years ago

Hi, it doesn't work on my voidlinux install. I installed i3pystatus from pip but I needed to install python3-gobject module, that contains the gi module.

SpidFightFR commented 2 years ago

installed python-gobject, works now smirk_cat can you put it in the readme?

Yup, it worked for me too, thanks for the tip !

jeremy-neale commented 4 months ago

The normal pip-install python-gobject didn't work for me.

I needed:

pip3 install PyGObject and then it worked. Thanks!