0

Recently I decided to update Pywikibot to version 7 since the legacy API had been deprecated in Fandom wiki. Far from solving the issue, I ended up bashing my head with "No user is logged in" error instead. I had user-config.py and the credentials configured correctly according to the latest Pywikibot documentation.

Do you want to accept these changes? ([y]es, [N]o): y
WARNING: No user is logged in on site fkg:en
Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\pywikibot\page\_decorators.py", line 32, in handle
    func(self, *args, **kwargs)
  File "C:\Python38\lib\site-packages\pywikibot\page\_pages.py", line 1260, in _save
    done = self.site.editpage(self, summary=summary, minor=minor,
  File "C:\Python38\lib\site-packages\pywikibot\site\_decorators.py", line 89, in callee
    raise UserRightsError('User "{}" does not have required '
pywikibot.exceptions.UserRightsError: User "None" does not have required user right "edit"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\FKGProcessing-master\src\update_lists.py", line 36, in save
    page.save(summary=comment or self.comment,
  File "C:\Python38\lib\site-packages\pywikibot\page\_pages.py", line 1248, in save
    self._save(summary=summary, watch=watch, minor=minor, botflag=botflag,
  File "C:\Python38\lib\site-packages\pywikibot\page\_decorators.py", line 53, in wrapper
    handle(func, self, *args, **kwargs)
  File "C:\Python38\lib\site-packages\pywikibot\page\_decorators.py", line 45, in handle
    raise OtherPageSaveError(self, err)
pywikibot.exceptions.OtherPageSaveError: Edit to page [[Module:Equipment/Names]] failed:
User "None" does not have required user right "edit"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\FKGProcessing-master\src\update_lists.py", line 139, in <module>
    run(sys.argv)
  File "D:\FKGProcessing-master\src\update_lists.py", line 136, in run
    bot.update()
  File "D:\FKGProcessing-master\src\update_lists.py", line 108, in update
    my.update_equipment_names()
  File "D:\FKGProcessing-master\src\update_lists.py", line 76, in update_equipment_names
    my.save(text, page)
  File "D:\FKGProcessing-master\src\update_lists.py", line 38, in save
    except pywikibot.LockedPage:
AttributeError: module 'pywikibot' has no attribute 'LockedPage'

Here's the script I intended to run: https://github.com/HydroKirby/FKGProcessing/blob/master/src/update_lists.py

1 Answers1

1

The update_lists.py script looks wrong. Line 38 contains

except pywikibot.LockedPage:

but it should be

except pywikibot.exceptions.LockedPageError:

since Pywikibot 7. You have to login first. There is a login.py script which can be used: https://doc.wikimedia.org/pywikibot/stable/utilities/scripts_ref.html#module-pywikibot.scripts.login. If you are using Pywikibot as a site-package you have to update your bot to release 7.4 and call this script:

pwb.exe login

For previous Pywikibot releases 7.0 you can use:

pwb.exe shell
>>> site = pywikibot.Site()
>>> site.login()

The latter also works with IDLE or as a script but you have to

import pywikibot

first.

Refer the documentation for parameters which are available for Siteconstructor function and loginmethod:

Prod
  • 25
  • 4
xqt
  • 280
  • 1
  • 11