import pywikibot
site = pywikibot.Site('test', 'wikipedia')
site
APISite("test", "wikipedia")
page = pywikibot.Page(site, 'test')
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-5-0ec62825cef5> in <module>()
----> 1 page = pywikibot.Page(site, 'test')

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

/srv/paws/pwb/pywikibot/page.py in __init__(self, source, title, ns)
   2273                 raise ValueError('Title must be specified and not empty '
   2274                                  'if source is a Site.')
-> 2275         super(Page, self).__init__(source, title, ns)
   2276 
   2277     @property

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

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

/srv/paws/pwb/pywikibot/page.py in __init__(self, text, source, default_namespace)
   5516         # See bug T104864, default_namespace might have been deleted.
   5517         try:
-> 5518             self._defaultns = self._source.namespaces[default_namespace]
   5519         except KeyError:
   5520             self._defaultns = default_namespace

/srv/paws/pwb/pywikibot/site.py in namespaces(self)
   1041         """Return dict of valid namespaces on this wiki."""
   1042         if not hasattr(self, '_namespaces'):
-> 1043             self._namespaces = NamespacesDict(self._build_namespaces())
   1044         return self._namespaces
   1045 

/srv/paws/pwb/pywikibot/site.py in _build_namespaces(self)
   2665         # For versions lower than 1.14, APISite needs to override
   2666         # the defaults defined in Namespace.
-> 2667         is_mw114 = self.mw_version >= '1.14'
   2668 
   2669         for nsdata in self.siteinfo.get('namespaces', cache=False).values():

/srv/paws/pwb/pywikibot/site.py in mw_version(self)
   2799         mw_ver, cache_time = getattr(self, '_mw_version_time', (None, None))
   2800         if mw_ver is None or time.time() - cache_time > 60 * 60 * 24:
-> 2801             mw_ver = MediaWikiVersion(self.version())
   2802             setattr(self, '_mw_version_time', (mw_ver, time.time()))
   2803         return mw_ver

/srv/paws/pwb/pywikibot/site.py in version(self)
   2782             try:
   2783                 version = self.siteinfo.get('generator',
-> 2784                                             expiry=1).split(' ')[1]
   2785             except pywikibot.data.api.APIError:
   2786                 # May occur if you are not logged in (no API read permissions).

/srv/paws/pwb/pywikibot/site.py in get(self, key, get_default, cache, expiry)
   1691                 elif not Siteinfo._is_expired(cached[1], expiry):
   1692                     return copy.deepcopy(cached[0])
-> 1693         preloaded = self._get_general(key, expiry)
   1694         if not preloaded:
   1695             preloaded = self._get_siteinfo(key, expiry)[key]

/srv/paws/pwb/pywikibot/site.py in _get_general(self, key, expiry)
   1637                     .format("', '".join(props)), _logger)
   1638             props += ['general']
-> 1639             default_info = self._get_siteinfo(props, expiry)
   1640             for prop in props:
   1641                 self._cache[prop] = default_info[prop]

/srv/paws/pwb/pywikibot/site.py in _get_siteinfo(self, prop, expiry)
   1560         request._warning_handler = warn_handler
   1561         try:
-> 1562             data = request.submit()
   1563         except api.APIError as e:
   1564             if e.code == 'siunknown_siprop':

/srv/paws/pwb/pywikibot/data/api.py in submit(self)
   2422         cached_available = self._load_cache()
   2423         if not cached_available:
-> 2424             self._data = super(CachedRequest, self).submit()
   2425             self._write_cache(self._data)
   2426         else:

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

NoUsername: Failed OAuth authentication for wikipedia:test: The authorization headers in your request are for a user that does not exist here
page.exists()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-6-93899efda95d> in <module>()
----> 1 page.exists()

NameError: name 'page' is not defined