Skip to content
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

ImportError: No module named gi.repository #2

Closed
ExcaliburZero opened this issue May 8, 2015 · 13 comments
Closed

ImportError: No module named gi.repository #2

ExcaliburZero opened this issue May 8, 2015 · 13 comments
Assignees
Labels

Comments

@ExcaliburZero
Copy link
Owner

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
Copy link
Owner Author

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
Copy link
Owner Author

This issue on another project seems to be relevant:

@ExcaliburZero
Copy link
Owner Author

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

@ExcaliburZero
Copy link
Owner Author

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

@ExcaliburZero
Copy link
Owner Author

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
Copy link
Owner Author

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
Copy link
Owner Author

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
Copy link
Owner Author

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

@ExcaliburZero
Copy link
Owner Author

This issue from the Travis CI repository is related:

This issue may also be relevant:

@ExcaliburZero
Copy link
Owner Author

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
Copy link
Owner Author

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

@ExcaliburZero
Copy link
Owner Author

This page may be helpful:

@ExcaliburZero
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant