最近,我决定将Pywikibot更新为version 7,因为旧式API已经在粉丝wiki中被废弃。我非但没有解决这个问题,反而用“没有用户登录”的错误来抨击我的头。我根据最新的Pywikibot文档正确配置了user-config.py和凭据。
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'下面是我打算运行的脚本:https://github.com/HydroKirby/FKGProcessing/blob/master/src/update_lists.py
发布于 2022-07-07 10:37:28
update_lists.py脚本看起来不对。第38行
except pywikibot.LockedPage:但它应该是
except pywikibot.exceptions.LockedPageError:从Pywikibot 7开始。你必须先登录。有一个可以使用的login.py脚本:https://doc.wikimedia.org/pywikibot/stable/utilities/scripts_ref.html#module-pywikibot.scripts.login。如果您使用Pywikibot作为站点包,则必须更新bot以发布7.4版本,并调用以下脚本:
pwb.exe login对于以前的Pywikibot版本7.0,您可以使用:
pwb.exe shell
>>> site = pywikibot.Site()
>>> site.login()后者也适用于空闲或脚本,但您必须
import pywikibot第一。
请参阅可用于Site构造函数和login方法的参数文档:
https://stackoverflow.com/questions/72272720
复制相似问题