ExcaliburZero / jekyll-helper

A program that serves as a basic GUI for Jekyll.
MIT License
4 stars 0 forks source link

ImportError: No module named gi.repository #2

Closed ExcaliburZero closed 9 years ago

ExcaliburZero commented 9 years ago

The following errors are currently showing up in Travis CI. Python seems unable to import gi.repository.

======================================================================
ERROR: Failure: ImportError (No module named gi.repository)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/loader.py", line 414, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/travis/build/ExcaliburZero/jekyll-helper/jekyll_helper/__init__.py", line 10, in <module>
    from gi.repository import Gtk # pylint: disable=E0611
ImportError: No module named gi.repository
======================================================================
ERROR: Failure: ImportError (No module named gi.repository)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/loader.py", line 414, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/travis/build/ExcaliburZero/jekyll-helper/jekyll_helper_lib/__init__.py", line 11, in <module>
    from . helpers import set_up_logging
  File "/home/travis/build/ExcaliburZero/jekyll-helper/jekyll_helper_lib/helpers.py", line 13, in <module>
    from . Builder import Builder
  File "/home/travis/build/ExcaliburZero/jekyll-helper/jekyll_helper_lib/Builder.py", line 10, in <module>
    from gi.repository import GObject, Gtk # pylint: disable=E0611
ImportError: No module named gi.repository
======================================================================
ERROR: Failure: ImportError (No module named gi.repository)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/loader.py", line 414, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/travis/build/ExcaliburZero/jekyll-helper/tests/test_example.py", line 12, in <module>
    from jekyll_helper import AboutJekyllHelperDialog
  File "/home/travis/build/ExcaliburZero/jekyll-helper/jekyll_helper/__init__.py", line 10, in <module>
    from gi.repository import Gtk # pylint: disable=E0611
ImportError: No module named gi.repository
ExcaliburZero commented 9 years ago

This seems to be an issue with the gi module of Python not being installed. This module seems to be related to the GObject and Gtk modules.

It seems that PyGObject needs to be installed via Pip.

This question on AskUbuntu may be helpful:

ExcaliburZero commented 9 years ago

This issue on another project seems to be relevant:

ExcaliburZero commented 9 years ago

The following repository's Travis CI config seems to be able to solve this problem:

ExcaliburZero commented 9 years ago

It seems that this commit in another repository was able to fix this same error:

ExcaliburZero commented 9 years ago

It looks like the issue is that apt-get can be used to install Python dependencies but they are not noticed by Travis CI unless the following code is in the config file.

virtualenv:
  system_site_packages: true

See: http://danielnouri.org/notes/2012/11/23/use-apt-get-to-install-python-dependencies-for-travis-ci/

ExcaliburZero commented 9 years ago

I think the issue has now been fixed. I just need to rebase and squash the commits and then I can work on the next error.

ExcaliburZero commented 9 years ago

However this seems to have caused another problem which causes Python versions 2.6, 3.3, 3.4, and nightly to not even get to the install process.

Example (Python 3.3):

$ source ~/virtualenv/python3.3_with_system_site_packages/bin/activate
/home/travis/build.sh: line 41: /home/travis/virtualenv/python3.3_with_system_site_packages/bin/activate: No such file or directory
The command "source ~/virtualenv/python3.3_with_system_site_packages/bin/activate" failed and exited with 1 during .
ExcaliburZero commented 9 years ago

I attempted to add sudo: required to the Travis CI config in attempt to fix the problems, however that didn't work.

ExcaliburZero commented 9 years ago

This issue from the Travis CI repository is related:

This issue may also be relevant:

ExcaliburZero commented 9 years ago

According to the user dstufft in the Travis CI issue 2231, a solution like the following could work:

$ sudo add-apt-repository -y ppa:fkrull/deadsnakes
$ sudo apt-get -y update
$ sudo apt-get install python3.3 python3.3-dev
$ virtualenv -p /usr/bin/python3.3 ~/virtualenvs/3.3_debian
$ source ~/virtualenvs/3.3_debian/bin/activate
ExcaliburZero commented 9 years ago

I tried implementing dsufft's solution, but I have not gotten it to work yet.

ExcaliburZero commented 9 years ago

This page may be helpful:

ExcaliburZero commented 9 years ago

After doing so more tests I decided to revert to using system_site_packages: true to allow the installation of Python libraries. However, I did have to remove testing for all versions of Python except 3.2 and 2.7, as the others did not allow the use of this method.