import pywikibot

site = pywikibot.Site("wikidata","wikidata")
repo = site.data_repository()
repo = site.data_repository
item = pywikibot.ItemPage(repo, 'Q43049')
item
ItemPage('Q43049')
item.get()
WARNING: API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here

NoUsernameTraceback (most recent call last)
<ipython-input-52-0623a9bcc987> in <module>()
----> 1 item.get()

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in get(self, force, get_redirect, *args, **kwargs)
   3859         @raise NotImplementedError: a value in args or kwargs
   3860         """
-> 3861         data = super(ItemPage, self).get(force, *args, **kwargs)
   3862 
   3863         if self.isRedirectPage() and not get_redirect:

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in get(self, force, *args, **kwargs)
   3474                 self.claims[pid] = []
   3475                 for claim in self._content['claims'][pid]:
-> 3476                     c = Claim.fromJSON(self.repo, claim)
   3477                     c.on_item = self
   3478                     self.claims[pid].append(c)

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in fromJSON(cls, site, data)
   4270             # The default covers string, url types
   4271             claim.target = Claim.TARGET_CONVERTER.get(
-> 4272                 claim.type, lambda value, site: value)(value, site)
   4273         if 'rank' in data:  # References/Qualifiers don't have ranks
   4274             claim.rank = data['rank']

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in <lambda>(value, site)
   4210             ItemPage(site, 'Q' + str(value['numeric-id'])),
   4211         'commonsMedia': lambda value, site:
-> 4212             FilePage(pywikibot.Site('commons', 'commons'), value),
   4213         'globe-coordinate': pywikibot.Coordinate.fromWikibase,
   4214         'time': lambda value, site: pywikibot.WbTime.fromWikibase(value),

/srv/paws/lib/python3.4/site-packages/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1412                              cls, depth)
   1413                     del __kw[old_arg]
-> 1414             return obj(*__args, **__kw)
   1415 
   1416         if not __debug__:

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in __init__(self, source, title)
   2242         """Constructor."""
   2243         self._file_revisions = {}  # dictionary to cache File history.
-> 2244         super(FilePage, self).__init__(source, title, 6)
   2245         if self.namespace() != 6:
   2246             raise ValueError(u"'%s' is not in the file namespace!" % title)

/srv/paws/lib/python3.4/site-packages/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1412                              cls, depth)
   1413                     del __kw[old_arg]
-> 1414             return obj(*__args, **__kw)
   1415 
   1416         if not __debug__:

/srv/paws/lib/python3.4/site-packages/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1412                              cls, depth)
   1413                     del __kw[old_arg]
-> 1414             return obj(*__args, **__kw)
   1415 
   1416         if not __debug__:

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in __init__(self, source, title, ns)
   2118                 raise ValueError(u'Title must be specified and not empty '
   2119                                  'if source is a Site.')
-> 2120         super(Page, self).__init__(source, title, ns)
   2121 
   2122     @deprecate_arg("get_redirect", None)

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in __init__(self, source, title, ns)
    132 
    133         if isinstance(source, pywikibot.site.BaseSite):
--> 134             self._link = Link(title, source=source, defaultNamespace=ns)
    135             self._revisions = {}
    136         elif isinstance(source, Page):

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in __init__(self, text, source, defaultNamespace)
   4877         # See bug T104864, defaultNamespace might have been deleted.
   4878         try:
-> 4879             self._defaultns = self._source.namespaces[defaultNamespace]
   4880         except KeyError:
   4881             self._defaultns = defaultNamespace

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in namespaces(self)
   1007         """Return dict of valid namespaces on this wiki."""
   1008         if not hasattr(self, '_namespaces'):
-> 1009             self._namespaces = NamespacesDict(self._build_namespaces())
   1010         return self._namespaces
   1011 

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _build_namespaces(self)
   2577         # For versions lower than 1.14, APISite needs to override
   2578         # the defaults defined in Namespace.
-> 2579         is_mw114 = MediaWikiVersion(self.version()) >= MediaWikiVersion('1.14')
   2580 
   2581         for nsdata in self.siteinfo.get('namespaces', cache=False).values():

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in version(self)
   2684         if not version:
   2685             try:
-> 2686                 version = self.siteinfo.get('generator', expiry=1).split(' ')[1]
   2687             except pywikibot.data.api.APIError:
   2688                 # May occur if you are not logged in (no API read permissions).

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in get(self, key, get_default, cache, expiry)
   1649                 elif not Siteinfo._is_expired(cached[1], expiry):
   1650                     return copy.deepcopy(cached[0])
-> 1651         preloaded = self._get_general(key, expiry)
   1652         if not preloaded:
   1653             preloaded = self._get_siteinfo(key, expiry)[key]

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _get_general(self, key, expiry)
   1595                         u"', '".join(props)), _logger)
   1596             props += ['general']
-> 1597             default_info = self._get_siteinfo(props, expiry)
   1598             for prop in props:
   1599                 self._cache[prop] = default_info[prop]

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _get_siteinfo(self, prop, expiry)
   1521             # warnings are handled later
   1522             request._warning_handler = warn_handler
-> 1523             data = request.submit()
   1524         except api.APIError as e:
   1525             if e.code == 'siunknown_siprop':

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   2334         cached_available = self._load_cache()
   2335         if not cached_available:
-> 2336             self._data = super(CachedRequest, self).submit()
   2337             self._write_cache(self._data)
   2338         else:

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   2167             if 'mwoauth-invalid-authorization' in code:
   2168                 raise NoUsername('Failed OAuth authentication for %s: %s'
-> 2169                                  % (self.site, info))
   2170             # raise error
   2171             try:

NoUsername: Failed OAuth authentication for commons:commons: The authorization headers in your request are for a user that does not exist here