New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jecogeo opened this Issue May 6, 2017 · 11 comments

Comments

2 participants
@jecogeo

jecogeo commented May 6, 2017

When I execute Battery Monitor file located in /usr/share/battery-monitor, everything goes straightforward. I usually start the application through Ubuntu Dash. However the battery-monitor command in the terminal returns:

Traceback (most recent call last):
File "/usr/share/battery-monitor/battery-monitor.py", line 12, in <module>
gi.require_version('Notify', '0.7')
AttributeError: module 'gi' has no attribute 'require_version' 

I'm would like to insert the battery-monitor command in Startup Applications.

Any idea?

@maateen

This comment has been minimized.

Show comment
Hide comment
@maateen

maateen May 7, 2017

Owner

Please let me know about your OS and how you have installed Battery Monitor.

Owner

maateen commented May 7, 2017

Please let me know about your OS and how you have installed Battery Monitor.

@jecogeo

This comment has been minimized.

Show comment
Hide comment
@jecogeo

jecogeo May 8, 2017

Oh, sure. Forgot it. I'm using Ubuntu 16.04 LTS and installed Battery Monitor via sudo apt-get install battery-monitor.

jecogeo commented May 8, 2017

Oh, sure. Forgot it. I'm using Ubuntu 16.04 LTS and installed Battery Monitor via sudo apt-get install battery-monitor.

@maateen

This comment has been minimized.

Show comment
Hide comment
@maateen

maateen May 9, 2017

Owner

I think you're missing python-gobject somehow. Please install it.

Owner

maateen commented May 9, 2017

I think you're missing python-gobject somehow. Please install it.

@jecogeo

This comment has been minimized.

Show comment
Hide comment
@jecogeo

jecogeo May 9, 2017

python-gobject is already the newest version (3.20.0-0ubuntu1)

jecogeo commented May 9, 2017

python-gobject is already the newest version (3.20.0-0ubuntu1)

@maateen

This comment has been minimized.

Show comment
Hide comment
@maateen

maateen May 18, 2017

Owner

Sorry for my late reply. Can you please show me the command line output of these commands:

which python3
python3 -c "import gi; print(gi.__spec__)"
python3 -c "import gi; print(gi.__dict__)"
Owner

maateen commented May 18, 2017

Sorry for my late reply. Can you please show me the command line output of these commands:

which python3
python3 -c "import gi; print(gi.__spec__)"
python3 -c "import gi; print(gi.__dict__)"

@maateen maateen added the help wanted label May 18, 2017

@jecogeo

This comment has been minimized.

Show comment
Hide comment
@jecogeo

jecogeo May 18, 2017

jeco@jeco-pc  ~  which python3
/home/jeco/anaconda3/bin/python3
jeco@jeco-pc  ~  python3 -c "import gi; print(gi.spec)"
ModuleSpec(name='gi', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fe5ecbb93c8>, origin='/home/jeco/anaconda3/lib/python3.5/site-packages/gi/init.py', submodule_search_locations=['/home/jeco/anaconda3/lib/python3.5/site-packages/gi'])
jeco@jeco-pc  ~  python3 -c "import gi; print(gi.dict)"
{'loader': <_frozen_importlib_external.SourceFileLoader object at 0x7f9392f6c3c8>, 'builtins': {'ord': , 'BrokenPipeError': <class 'BrokenPipeError'>, 'PermissionError': <class 'PermissionError'>, 'UnicodeError': <class 'UnicodeError'>, 'EOFError': <class 'EOFError'>, 'print': , 'IndexError': <class 'IndexError'>, 'OSError': <class 'OSError'>, 'dir': , 'NotImplementedError': <class 'NotImplementedError'>, 'delattr': , 'ResourceWarning': <class 'ResourceWarning'>, 'classmethod': <class 'classmethod'>, 'staticmethod': <class 'staticmethod'>, 'hex': , 'InterruptedError': <class 'InterruptedError'>, 'list': <class 'list'>, 'spec': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>), 'SystemExit': <class 'SystemExit'>, 'NameError': <class 'NameError'>, 'debug': True, 'SyntaxError': <class 'SyntaxError'>, 'max': , 'BaseException': <class 'BaseException'>, 'getattr': , 'GeneratorExit': <class 'GeneratorExit'>, 'super': <class 'super'>, 'iter': , 'UnicodeDecodeError': <class 'UnicodeDecodeError'>, 'format': , 'None': None, 'StopAsyncIteration': <class 'StopAsyncIteration'>, 'exec': , 'locals': , 'min': , 'UserWarning': <class 'UserWarning'>, 'any': , 'OverflowError': <class 'OverflowError'>, 'EnvironmentError': <class 'OSError'>, 'NotADirectoryError': <class 'NotADirectoryError'>, 'type': <class 'type'>, 'RuntimeError': <class 'RuntimeError'>, 'Ellipsis': Ellipsis, 'sum': , 'set': <class 'set'>, 'FileExistsError': <class 'FileExistsError'>, 'setattr': , 'package': '', 'isinstance': , 'RuntimeWarning': <class 'RuntimeWarning'>, 'ProcessLookupError': <class 'ProcessLookupError'>, 'NotImplemented': NotImplemented, 'zip': <class 'zip'>, 'issubclass': , 'IOError': <class 'OSError'>, 'eval': , 'filter': <class 'filter'>, 'FileNotFoundError': <class 'FileNotFoundError'>, 'credits': Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
for supporting Python development. See www.python.org for more information., 'sorted': , 'open': , 'hasattr': , 'UnicodeEncodeError': <class 'UnicodeEncodeError'>, 'bool': <class 'bool'>, 'dict': <class 'dict'>, 'AttributeError': <class 'AttributeError'>, 'float': <class 'float'>, 'TabError': <class 'TabError'>, 'ImportWarning': <class 'ImportWarning'>, 'bytes': <class 'bytes'>, 'pow': , 'enumerate': <class 'enumerate'>, 'loader': <class '_frozen_importlib.BuiltinImporter'>, 'globals': , 'ChildProcessError': <class 'ChildProcessError'>, 'StopIteration': <class 'StopIteration'>, 'FutureWarning': <class 'FutureWarning'>, 'import': , 'MemoryError': <class 'MemoryError'>, 'PendingDeprecationWarning': <class 'PendingDeprecationWarning'>, 'ConnectionRefusedError': <class 'ConnectionRefusedError'>, 'SystemError': <class 'SystemError'>, 'TypeError': <class 'TypeError'>, 'next': , 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'ArithmeticError': <class 'ArithmeticError'>, 'LookupError': <class 'LookupError'>, 'ascii': , 'id': , 'slice': <class 'slice'>, 'bytearray': <class 'bytearray'>, 'ImportError': <class 'ImportError'>, 'oct': , 'BufferError': <class 'BufferError'>, 'callable': , 'doc': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the nil' object; Ellipsis represents ...' in slices.", 'reversed': <class 'reversed'>, 'object': <class 'object'>, 'len': , 'frozenset': <class 'frozenset'>, 'round': , 'Exception': <class 'Exception'>, 'hash': , 'AssertionError': <class 'AssertionError'>, 'ConnectionAbortedError': <class 'ConnectionAbortedError'>, 'RecursionError': <class 'RecursionError'>, 'range': <class 'range'>, 'ValueError': <class 'ValueError'>, 'abs': , 'compile': , 'False': False, 'chr': , 'bin': , 'UnboundLocalError': <class 'UnboundLocalError'>, 'str': <class 'str'>, 'UnicodeTranslateError': <class 'UnicodeTranslateError'>, 'map': <class 'map'>, 'DeprecationWarning': <class 'DeprecationWarning'>, 'property': <class 'property'>, 'TimeoutError': <class 'TimeoutError'>, 'vars': , 'BytesWarning': <class 'BytesWarning'>, 'ConnectionResetError': <class 'ConnectionResetError'>, 'SyntaxWarning': <class 'SyntaxWarning'>, 'True': True, 'ConnectionError': <class 'ConnectionError'>, 'KeyboardInterrupt': <class 'KeyboardInterrupt'>, 'help': Type help() for interactive help, or help(object) for help about object., 'ReferenceError': <class 'ReferenceError'>, 'build_class': , 'all': , 'tuple': <class 'tuple'>, 'Warning': <class 'Warning'>, 'int': <class 'int'>, 'memoryview': <class 'memoryview'>, 'BlockingIOError': <class 'BlockingIOError'>, 'copyright': Copyright (c) 2001-2016 Python Software Foundation.
All Rights Reserved.

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved., 'UnicodeWarning': <class 'UnicodeWarning'>, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'divmod': , 'IndentationError': <class 'IndentationError'>, 'complex': <class 'complex'>, 'ZeroDivisionError': <class 'ZeroDivisionError'>, 'IsADirectoryError': <class 'IsADirectoryError'>, 'FloatingPointError': <class 'FloatingPointError'>, 'repr': , 'license': Type license() to see the full license text, 'name': 'builtins', 'input': , 'KeyError': <class 'KeyError'>}, 'doc': None, 'file': '/home/jeco/anaconda3/lib/python3.5/site-packages/gi/init.py', 'cached': '/home/jeco/anaconda3/lib/python3.5/site-packages/gi/pycache/init.cpython-35.pyc', 'requests': <module 'requests' from '/home/jeco/anaconda3/lib/python3.5/site-packages/requests/init.py'>, 'package': 'gi', 'save_file': <function save_file at 0x7f9392f538c8>, 'spec': ModuleSpec(name='gi', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f9392f6c3c8>, origin='/home/jeco/anaconda3/lib/python3.5/site-packages/gi/init.py', submodule_search_locations=['/home/jeco/anaconda3/lib/python3.5/site-packages/gi']), 'path': ['/home/jeco/anaconda3/lib/python3.5/site-packages/gi'], 'sys': <module 'sys' (built-in)>, 'json': <module 'json' from '/home/jeco/anaconda3/lib/python3.5/json/init.py'>, 'name': 'gi', 'GIST_API_URL': 'https://api.github.com/gists', 'GistError': <class 'gi.GistError'>}

jecogeo commented May 18, 2017

jeco@jeco-pc  ~  which python3
/home/jeco/anaconda3/bin/python3
jeco@jeco-pc  ~  python3 -c "import gi; print(gi.spec)"
ModuleSpec(name='gi', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fe5ecbb93c8>, origin='/home/jeco/anaconda3/lib/python3.5/site-packages/gi/init.py', submodule_search_locations=['/home/jeco/anaconda3/lib/python3.5/site-packages/gi'])
jeco@jeco-pc  ~  python3 -c "import gi; print(gi.dict)"
{'loader': <_frozen_importlib_external.SourceFileLoader object at 0x7f9392f6c3c8>, 'builtins': {'ord': , 'BrokenPipeError': <class 'BrokenPipeError'>, 'PermissionError': <class 'PermissionError'>, 'UnicodeError': <class 'UnicodeError'>, 'EOFError': <class 'EOFError'>, 'print': , 'IndexError': <class 'IndexError'>, 'OSError': <class 'OSError'>, 'dir': , 'NotImplementedError': <class 'NotImplementedError'>, 'delattr': , 'ResourceWarning': <class 'ResourceWarning'>, 'classmethod': <class 'classmethod'>, 'staticmethod': <class 'staticmethod'>, 'hex': , 'InterruptedError': <class 'InterruptedError'>, 'list': <class 'list'>, 'spec': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>), 'SystemExit': <class 'SystemExit'>, 'NameError': <class 'NameError'>, 'debug': True, 'SyntaxError': <class 'SyntaxError'>, 'max': , 'BaseException': <class 'BaseException'>, 'getattr': , 'GeneratorExit': <class 'GeneratorExit'>, 'super': <class 'super'>, 'iter': , 'UnicodeDecodeError': <class 'UnicodeDecodeError'>, 'format': , 'None': None, 'StopAsyncIteration': <class 'StopAsyncIteration'>, 'exec': , 'locals': , 'min': , 'UserWarning': <class 'UserWarning'>, 'any': , 'OverflowError': <class 'OverflowError'>, 'EnvironmentError': <class 'OSError'>, 'NotADirectoryError': <class 'NotADirectoryError'>, 'type': <class 'type'>, 'RuntimeError': <class 'RuntimeError'>, 'Ellipsis': Ellipsis, 'sum': , 'set': <class 'set'>, 'FileExistsError': <class 'FileExistsError'>, 'setattr': , 'package': '', 'isinstance': , 'RuntimeWarning': <class 'RuntimeWarning'>, 'ProcessLookupError': <class 'ProcessLookupError'>, 'NotImplemented': NotImplemented, 'zip': <class 'zip'>, 'issubclass': , 'IOError': <class 'OSError'>, 'eval': , 'filter': <class 'filter'>, 'FileNotFoundError': <class 'FileNotFoundError'>, 'credits': Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
for supporting Python development. See www.python.org for more information., 'sorted': , 'open': , 'hasattr': , 'UnicodeEncodeError': <class 'UnicodeEncodeError'>, 'bool': <class 'bool'>, 'dict': <class 'dict'>, 'AttributeError': <class 'AttributeError'>, 'float': <class 'float'>, 'TabError': <class 'TabError'>, 'ImportWarning': <class 'ImportWarning'>, 'bytes': <class 'bytes'>, 'pow': , 'enumerate': <class 'enumerate'>, 'loader': <class '_frozen_importlib.BuiltinImporter'>, 'globals': , 'ChildProcessError': <class 'ChildProcessError'>, 'StopIteration': <class 'StopIteration'>, 'FutureWarning': <class 'FutureWarning'>, 'import': , 'MemoryError': <class 'MemoryError'>, 'PendingDeprecationWarning': <class 'PendingDeprecationWarning'>, 'ConnectionRefusedError': <class 'ConnectionRefusedError'>, 'SystemError': <class 'SystemError'>, 'TypeError': <class 'TypeError'>, 'next': , 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'ArithmeticError': <class 'ArithmeticError'>, 'LookupError': <class 'LookupError'>, 'ascii': , 'id': , 'slice': <class 'slice'>, 'bytearray': <class 'bytearray'>, 'ImportError': <class 'ImportError'>, 'oct': , 'BufferError': <class 'BufferError'>, 'callable': , 'doc': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the nil' object; Ellipsis represents ...' in slices.", 'reversed': <class 'reversed'>, 'object': <class 'object'>, 'len': , 'frozenset': <class 'frozenset'>, 'round': , 'Exception': <class 'Exception'>, 'hash': , 'AssertionError': <class 'AssertionError'>, 'ConnectionAbortedError': <class 'ConnectionAbortedError'>, 'RecursionError': <class 'RecursionError'>, 'range': <class 'range'>, 'ValueError': <class 'ValueError'>, 'abs': , 'compile': , 'False': False, 'chr': , 'bin': , 'UnboundLocalError': <class 'UnboundLocalError'>, 'str': <class 'str'>, 'UnicodeTranslateError': <class 'UnicodeTranslateError'>, 'map': <class 'map'>, 'DeprecationWarning': <class 'DeprecationWarning'>, 'property': <class 'property'>, 'TimeoutError': <class 'TimeoutError'>, 'vars': , 'BytesWarning': <class 'BytesWarning'>, 'ConnectionResetError': <class 'ConnectionResetError'>, 'SyntaxWarning': <class 'SyntaxWarning'>, 'True': True, 'ConnectionError': <class 'ConnectionError'>, 'KeyboardInterrupt': <class 'KeyboardInterrupt'>, 'help': Type help() for interactive help, or help(object) for help about object., 'ReferenceError': <class 'ReferenceError'>, 'build_class': , 'all': , 'tuple': <class 'tuple'>, 'Warning': <class 'Warning'>, 'int': <class 'int'>, 'memoryview': <class 'memoryview'>, 'BlockingIOError': <class 'BlockingIOError'>, 'copyright': Copyright (c) 2001-2016 Python Software Foundation.
All Rights Reserved.

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved., 'UnicodeWarning': <class 'UnicodeWarning'>, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'divmod': , 'IndentationError': <class 'IndentationError'>, 'complex': <class 'complex'>, 'ZeroDivisionError': <class 'ZeroDivisionError'>, 'IsADirectoryError': <class 'IsADirectoryError'>, 'FloatingPointError': <class 'FloatingPointError'>, 'repr': , 'license': Type license() to see the full license text, 'name': 'builtins', 'input': , 'KeyError': <class 'KeyError'>}, 'doc': None, 'file': '/home/jeco/anaconda3/lib/python3.5/site-packages/gi/init.py', 'cached': '/home/jeco/anaconda3/lib/python3.5/site-packages/gi/pycache/init.cpython-35.pyc', 'requests': <module 'requests' from '/home/jeco/anaconda3/lib/python3.5/site-packages/requests/init.py'>, 'package': 'gi', 'save_file': <function save_file at 0x7f9392f538c8>, 'spec': ModuleSpec(name='gi', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f9392f6c3c8>, origin='/home/jeco/anaconda3/lib/python3.5/site-packages/gi/init.py', submodule_search_locations=['/home/jeco/anaconda3/lib/python3.5/site-packages/gi']), 'path': ['/home/jeco/anaconda3/lib/python3.5/site-packages/gi'], 'sys': <module 'sys' (built-in)>, 'json': <module 'json' from '/home/jeco/anaconda3/lib/python3.5/json/init.py'>, 'name': 'gi', 'GIST_API_URL': 'https://api.github.com/gists', 'GistError': <class 'gi.GistError'>}

@maateen

This comment has been minimized.

Show comment
Hide comment
@maateen

maateen May 20, 2017

Owner

Thanks for your valuable information. Actually you are using /home/jeco/anaconda3/bin/python3 as your python executable instead of /usr/bin/python3. That's why the problem is occurring.

Perhaps, I will fix the problem by using /usr/bin/python3 instead of python3 in .desktop files and battery-monitor executable file.

Owner

maateen commented May 20, 2017

Thanks for your valuable information. Actually you are using /home/jeco/anaconda3/bin/python3 as your python executable instead of /usr/bin/python3. That's why the problem is occurring.

Perhaps, I will fix the problem by using /usr/bin/python3 instead of python3 in .desktop files and battery-monitor executable file.

@maateen maateen added bug and removed help wanted labels May 20, 2017

@maateen

This comment has been minimized.

Show comment
Hide comment
@maateen

maateen May 21, 2017

Owner

I have made a new commit in devel branch to fix this issue. Please try these and let me know the update:

wget https://github.com/maateen/battery-monitor/archive/devel.zip
unzip devel.zip
cd battery-monitor-devel
sudo make install

Also make sure you have installed all dependencies.

Owner

maateen commented May 21, 2017

I have made a new commit in devel branch to fix this issue. Please try these and let me know the update:

wget https://github.com/maateen/battery-monitor/archive/devel.zip
unzip devel.zip
cd battery-monitor-devel
sudo make install

Also make sure you have installed all dependencies.

@jecogeo

This comment has been minimized.

Show comment
Hide comment
@jecogeo

jecogeo May 22, 2017

@maateen, thanks a lot. I installed battery-monitor as indicated. The command battery-monitor now executed like expected in the terminal. I also added the command to startup applications and it's now listed in processes list after reboot. So it's probably working like a charm (I've not seen notifications yet likely because of my battery status, but as it is listed in processes list I assume it is running ok). Thanks again.

jecogeo commented May 22, 2017

@maateen, thanks a lot. I installed battery-monitor as indicated. The command battery-monitor now executed like expected in the terminal. I also added the command to startup applications and it's now listed in processes list after reboot. So it's probably working like a charm (I've not seen notifications yet likely because of my battery status, but as it is listed in processes list I assume it is running ok). Thanks again.

@maateen

This comment has been minimized.

Show comment
Hide comment
@maateen

maateen May 22, 2017

Owner

Battery Monitor should run automatically at startup. You need not do so manually. If you have doubt about notification, please test it with following command:

/usr/share/battery-monitor/battery-monitor.py --test

Now sit tight and wait. You will see various notification for various situation. Let me know if any issue occurs. Otherwise, please close the bug if you can.

Owner

maateen commented May 22, 2017

Battery Monitor should run automatically at startup. You need not do so manually. If you have doubt about notification, please test it with following command:

/usr/share/battery-monitor/battery-monitor.py --test

Now sit tight and wait. You will see various notification for various situation. Let me know if any issue occurs. Otherwise, please close the bug if you can.

@jecogeo

This comment has been minimized.

Show comment
Hide comment
@jecogeo

jecogeo May 22, 2017

It's working very well now. Thanks for your help!
Best regards.

jecogeo commented May 22, 2017

It's working very well now. Thanks for your help!
Best regards.

@jecogeo jecogeo closed this May 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment