import pywikibot
from pywikibot.data import api
itemtitle = 'Beatles'
# Login to wikidata
site = pywikibot.Site("wikidata", "wikidata")
#repo = site.data_repository()
#token = repo.token(pywikibot.Page(repo, 'Main Page'), 'edit')
---------------------------------------------------------------------------
UnknownSite                               Traceback (most recent call last)
<ipython-input-9-3c5386b619b3> in <module>()
      1 # Login to wikidata
----> 2 site = pywikibot.Site("mainak124", "wikidata")
      3 #repo = site.data_repository()
      4 #token = repo.token(pywikibot.Page(repo, 'Main Page'), 'edit')

/srv/paws/pwb/pywikibot/__init__.py in Site(code, fam, user, sysop, interface, url)
   1270     key = '%s:%s:%s:%s' % (interface.__name__, fam, code, user)
   1271     if key not in _sites or not isinstance(_sites[key], interface):
-> 1272         _sites[key] = interface(code=code, fam=fam, user=user, sysop=sysop)
   1273         debug(u"Instantiated %s object '%s'"
   1274               % (interface.__name__, _sites[key]), _logger)

/srv/paws/pwb/pywikibot/site.py in __init__(self, *args, **kwargs)
   7331     def __init__(self, *args, **kwargs):
   7332         """Constructor."""
-> 7333         super(DataSite, self).__init__(*args, **kwargs)
   7334         self._item_namespace = None
   7335         self._property_namespace = None

/srv/paws/pwb/pywikibot/site.py in __init__(self, code, fam, user, sysop)
   1839     def __init__(self, code, fam=None, user=None, sysop=None):
   1840         """Constructor."""
-> 1841         BaseSite.__init__(self, code, fam, user, sysop)
   1842         self._msgcache = {}
   1843         self._loginstatus = LoginStatus.NOT_ATTEMPTED

/srv/paws/pwb/pywikibot/site.py in __init__(self, code, fam, user, sysop)
    771             else:
    772                 raise UnknownSite(u"Language '%s' does not exist in family %s"
--> 773                                   % (self.__code, self.__family.name))
    774 
    775         self._username = [normalize_username(user), normalize_username(sysop)]

UnknownSite: Language 'mainak124' does not exist in family wikidata
params = { 'action' :'wbsearchentities' , 'format' : 'json' , 'language' : 'en', 'type' : 'item', 'search': itemtitle}
request = api.Request(site=site,**params)
request.submit()
WARNING: /srv/paws/lib/python3.6/site-packages/ipykernel_launcher.py:2: DeprecationWarning: Instead of using kwargs from Request.__init__, parameters for the request to the API should be added via the "parameters" parameter.
  

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-7-a4c276f31dcb> in <module>()
      1 params = { 'action' :'wbsearchentities' , 'format' : 'json' , 'language' : 'en', 'type' : 'item', 'search': itemtitle}
      2 request = api.Request(site=site,**params)
----> 3 request.submit()

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

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