import pywikibot

site = pywikibot.Site("es", "wikipedia")
page = pywikibot.Page(site, "Douglas Adams")
item = pywikibot.ItemPage.fromPage(page)

print(item)
WARNING: API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here
---------------------------------------------------------------------------
NoUsername                                Traceback (most recent call last)
<ipython-input-4-b85a264a186d> in <module>
      3 site = pywikibot.Site("es", "wikipedia")
      4 page = pywikibot.Page(site, "Douglas Adams")
----> 5 item = pywikibot.ItemPage.fromPage(page)
      6 
      7 print(item)

/srv/paws/pwb/pywikibot/page.py in fromPage(cls, page, lazy_load)
   4431         i._site = page.site
   4432         i._title = page.title(with_section=False)
-> 4433         if not lazy_load and not i.exists():
   4434             raise pywikibot.NoPage(i)
   4435         page._item = i

/srv/paws/pwb/pywikibot/page.py in exists(self)
   3884         if not hasattr(self, '_content'):
   3885             try:
-> 3886                 self.get(get_redirect=True)
   3887                 return True
   3888             except pywikibot.NoPage:

/srv/paws/pwb/pywikibot/page.py in get(self, force, get_redirect, *args, **kwargs)
   4481         @raise NotImplementedError: a value in args or kwargs
   4482         """
-> 4483         data = super(ItemPage, self).get(force, *args, **kwargs)
   4484 
   4485         if self.isRedirectPage() and not get_redirect:

/srv/paws/pwb/pywikibot/page.py in get(self, force, *args, **kwargs)
   3974                 self.claims[pid] = []
   3975                 for claim in self._content['claims'][pid]:
-> 3976                     c = Claim.fromJSON(self.repo, claim)
   3977                     c.on_item = self
   3978                     self.claims[pid].append(c)

/srv/paws/pwb/pywikibot/page.py in fromJSON(cls, site, data)
   4941             if claim.type in cls.types or claim.type == 'wikibase-property':
   4942                 claim.target = cls.TARGET_CONVERTER.get(
-> 4943                     claim.type, lambda value, site: value)(value, site)
   4944             else:
   4945                 pywikibot.warning(

/srv/paws/pwb/pywikibot/page.py in <lambda>(value, site)
   4849             PropertyPage(site, 'P' + str(value['numeric-id'])),
   4850         'commonsMedia': lambda value, site:
-> 4851             FilePage(pywikibot.Site('commons', 'commons'), value),  # T90492
   4852         'globe-coordinate': pywikibot.Coordinate.fromWikibase,
   4853         'geo-shape': pywikibot.WbGeoShape.fromWikibase,

/srv/paws/pwb/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1736                              cls, depth)
   1737                     del __kw[old_arg]
-> 1738             return obj(*__args, **__kw)
   1739 
   1740         if not __debug__:

/srv/paws/pwb/pywikibot/page.py in __init__(self, source, title)
   2450         """Initializer."""
   2451         self._file_revisions = {}  # dictionary to cache File history.
-> 2452         super(FilePage, self).__init__(source, title, 6)
   2453         if self.namespace() != 6:
   2454             raise ValueError("'%s' is not in the file namespace!" % title)

/srv/paws/pwb/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1736                              cls, depth)
   1737                     del __kw[old_arg]
-> 1738             return obj(*__args, **__kw)
   1739 
   1740         if not __debug__:

/srv/paws/pwb/pywikibot/page.py in __init__(self, source, title, ns)
   2299                 raise ValueError('Title must be specified and not empty '
   2300                                  'if source is a Site.')
-> 2301         super(Page, self).__init__(source, title, ns)
   2302 
   2303     @property

/srv/paws/pwb/pywikibot/page.py in __init__(self, source, title, ns)
    192 
    193         if isinstance(source, pywikibot.site.BaseSite):
--> 194             self._link = Link(title, source=source, default_namespace=ns)
    195             self._revisions = {}
    196         elif isinstance(source, Page):

/srv/paws/pwb/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1736                              cls, depth)
   1737                     del __kw[old_arg]
-> 1738             return obj(*__args, **__kw)
   1739 
   1740         if not __debug__:

/srv/paws/pwb/pywikibot/page.py in __init__(self, text, source, default_namespace)
   5563         # See bug T104864, default_namespace might have been deleted.
   5564         try:
-> 5565             self._defaultns = self._source.namespaces[default_namespace]
   5566         except KeyError:
   5567             self._defaultns = default_namespace

/srv/paws/pwb/pywikibot/site.py in namespaces(self)
   1018         """Return dict of valid namespaces on this wiki."""
   1019         if not hasattr(self, '_namespaces'):
-> 1020             self._namespaces = NamespacesDict(self._build_namespaces())
   1021         return self._namespaces
   1022 

/srv/paws/pwb/pywikibot/site.py in _build_namespaces(self)
   2638         _namespaces = {}
   2639 
-> 2640         for nsdata in self.siteinfo.get('namespaces', cache=False).values():
   2641             ns = nsdata.pop('id')
   2642             custom_name = None

/srv/paws/pwb/pywikibot/site.py in get(self, key, get_default, cache, expiry)
   1668                 elif not Siteinfo._is_expired(cached[1], expiry):
   1669                     return copy.deepcopy(cached[0])
-> 1670         preloaded = self._get_general(key, expiry)
   1671         if not preloaded:
   1672             preloaded = self._get_siteinfo(key, expiry)[key]

/srv/paws/pwb/pywikibot/site.py in _get_general(self, key, expiry)
   1614                     .format("', '".join(props)), _logger)
   1615             props += ['general']
-> 1616             default_info = self._get_siteinfo(props, expiry)
   1617             for prop in props:
   1618                 self._cache[prop] = default_info[prop]

/srv/paws/pwb/pywikibot/site.py in _get_siteinfo(self, prop, expiry)
   1537         request._warning_handler = warn_handler
   1538         try:
-> 1539             data = request.submit()
   1540         except api.APIError as e:
   1541             if e.code == 'siunknown_siprop':

/srv/paws/pwb/pywikibot/data/api.py in submit(self)
   2232         cached_available = self._load_cache()
   2233         if not cached_available:
-> 2234             self._data = super(CachedRequest, self).submit()
   2235             self._write_cache(self._data)
   2236         else:

/srv/paws/pwb/pywikibot/data/api.py in submit(self)
   2059                     continue
   2060                 raise NoUsername('Failed OAuth authentication for %s: %s'
-> 2061                                  % (self.site, info))
   2062             if code == 'cirrussearch-too-busy-error':  # T170647
   2063                 self.wait()

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