Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a web-browser named "Surf's Up!", and I have programmed the code and the interface, but when I try to run the app, an error message appears:

Traceback (most recent call last):
File "bin/surfs-up", line 32, in <module>
import surfs_up
File "/home/owner/surfs-up/surfs_up/", line 14, in <module>
from surfs_up import SurfsUpWindow
File "/home/owner/surfs-up/surfs_up/", line 10, in <module>
from gi.repository import Gtk, WebKit # pylint: disable=E0611
File "/usr/lib/python2.7/dist-packages/gi/", line 76, in load_module
File "/usr/lib/python2.7/dist-packages/gi/", line 222, in _load
File "/usr/lib/python2.7/dist-packages/gi/", line 90, in __init__
repository.require(namespace, version)
gi.RepositoryError: Requiring namespace 'Gtk' version '2.0', but '3.0' is already loaded

The code is as follows:

# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# This file is in the public domain

import gettext
from gettext import gettext as _

from gi.repository import Gtk, WebKit # pylint: disable=E0611
import logging
logger = logging.getLogger('surfs_up')

from surfs_up_lib import Window
from surfs_up.AboutSurfsUpDialog import AboutSurfsUpDialog
from surfs_up.PreferencesSurfsUpDialog import PreferencesSurfsUpDialog

# See for more details about how this class works
class SurfsUpWindow(Window):
    __gtype_name__ = "SurfsUpWindow"

    def finish_initializing(self, builder): # pylint: disable=E1002
        """Set up the main window"""
        super(SurfsUpWindow, self).finish_initializing(builder)

        self.AboutDialog = AboutSurfsUpDialog
        self.PreferencesDialog = PreferencesSurfsUpDialog

        # Code for other initialization actions should be added here.

        self.refresh = self.builder.get_object("refresh")
        self.urltext = self.builder.get_object("urltext")
        self.scroll = self.builder.get_object("scroll")
        self.toolbar = self.builder.get_object("toolbar")

        context = self.toolbar.get_style_context()

        self.webview = WebKit.WebView()


    def on_refresh_clicked(self, widget):
        print "Refreshing page.................................."
    def on_urltext_activate(self, widget):
        url = widget.get_text()
        print url

What do I need to fix to resolve the situation?

share|improve this question
up vote 0 down vote accepted
gi.RepositoryError: Requiring namespace 'Gtk' version '2.0', but '3.0' is already loaded

Based on that, I would try to switch the gtk version to the one that fits.


from gi.repository import Gtk, WebKit # pylint: disable=E0611    
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.