Manual talk:Pywikibot

Jump to: navigation, search

About this board


Please use one of the communication channels listed on Manual:Pywikibot/Communication rather than using this discussion board. There is very little traffic here, so it may take a while before you get a response.

By clicking "Add topic", you agree to our Terms of Use and agree to irrevocably release your text under the CC BY-SA 3.0 License and GFDL
KlosseBot (talkcontribs)

When i wrote login -all it write

*.wikidata is not a valid site, please remove it from your config

Traceback (most recent call last):

  File "/srv/paws/pwb/", line 262, in <module>

    if not main():

  File "/srv/paws/pwb/", line 255, in main

    run_python_file(filename, [filename] + args, argvu, file_package)

  File "/srv/paws/pwb/", line 121, in run_python_file


  File "/srv/paws/pwb/scripts/", line 190, in <module>


  File "/srv/paws/pwb/scripts/", line 163, in main

    for familyName in namedict:

RuntimeError: dictionary changed size during iteration

<class 'RuntimeError'>

CRITICAL: Closing network session.

In file i have

mylang = "wikidata" 

family = "wikidata" 

mylang = "cs"

family = "wikipedia" 

Xqt (talkcontribs)

You are redefine your default mylang and family which is wikipedia:cs then.

KlosseBot (talkcontribs)

How? Now i have just wikidata and still same response.

Reply to "wikidata is not valid site"

Uploading files with titles containing UTF-8 characters

Jc86035 (talkcontribs)

I was having trouble uploading python -keep -noverify -ignorewarn "/…/BSicon hÜST.svg" narrow formations. Do I need to escape the Ü?

Xqt (talkcontribs)

No idea. A traceback would help to find out the problem.

Jc86035 (talkcontribs)

(Third comment in thread; had previous revisions suppressed)

ERROR: Traceback (most recent call last):
 File "/…/Documents/pywikibot/pywikibot/data/", line 1558, in submit
   body=body, headers=headers)
 File "/…/Documents/pywikibot/pywikibot/tools/", line 1105, in wrapper
   return obj(*__args, **__kw)
 File "/…/Documents/pywikibot/pywikibot/comms/", line 279, in request
   r = fetch(baseuri, method, body, headers, **kwargs)
 File "/…/Documents/pywikibot/pywikibot/comms/", line 381, in fetch
 File "/…/Documents/pywikibot/pywikibot/comms/", line 297, in error_handling_callback
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 884: ordinal not in range(128)
Xqt (talkcontribs)

Seems the traceback isn't complete. I propose to file a bug at phabricator:

Jc86035 (talkcontribs)

(I've tried changing multiple instances of "ascii" in the config files to "utf-8" but there was no effect.)

KlosseBot (talkcontribs)

CMD writing no module named pywikibot when i start

Xqt (talkcontribs)

Looks like your cmd has opened the "../core/scripts" path. You should start from parent "core" path and use the wrapper script: login

2A00:1028:9192:FA72:F903:A911:3814:C073 (talkcontribs)

And when i write python login it said no module named request.

Xqt (talkcontribs)

You have to install request module as a side package first. Read the message and do as proposed. The message is:

Python module 'requests' is required.

Try running 'pip install requests'

do it with the command

pip install requests (talkcontribs)

I executed "pip install requests", it did so, but the same error doesn't go away. I tried both Python 3.6 and 2.7, it's the same with both.

Framawiki (talkcontribs)

Hello, can you type python version and post here what you obtain ? (talkcontribs)

This doesn't even work for me, as it gets an error in line 163 of

Xqt (talkcontribs)

Did you installed requests for both python releases? (talkcontribs)

I installed 2.7 after trying 3.6. I eventually got things to work after installing pip seperately again and then installing requests via "pip install requests" and restarting. I may have repeated this some times and can't pinpoint what got things to work, but i eventually got it to work.

KlosseBot (talkcontribs)

'pip install requests' doesnt work

Xqt (talkcontribs)

What is your python version? I propose using 2.7.9 or higher or 3.4 or higher release because the en:python package installer (pip) is shipped with these versions. Otherwise you have to install pip first.

KlosseBot (talkcontribs)

I have 3.4 but still it isnt pip in it. How do i install it?

Xqt (talkcontribs)

Maybe this could help.

Reply to "No module named pywikibot"
Jc86035 (talkcontribs)

I am trying to delay so it makes edits every eight seconds, so the script isn't stopped after every eight page moves by the Commons API. However, the script ignores settings for delay since the action is not an edit but a page move. How can I add a delay?

Xqt (talkcontribs)

Please file a bug at [ phabricator]. Seems this is a real bug and should ne solved

Jc86035 (talkcontribs)

Filed a bug, T173914.

Reply to "Delay in"
SamiIslam (talkcontribs)


Can a normal user use the pywikibot functionality from a wiki site to create a site from a text file? Or is that something only an admin would have to do on the server hosting the wiki?



Xqt (talkcontribs)

There is a script "" to do this but it is may be local community restrictions to allow or discard edits in this way.

Reply to "Pywikibot usage"
Jc86035 (talkcontribs)

Does update redirects as well to avoid creating double redirects?

This comment was hidden by Jc86035 (history)
Xqt (talkcontribs)

Currently not.

Jc86035 (talkcontribs)

Are there any scripts which do so?

XXN (talkcontribs)

Reply to "Moving pages"

how can i get transclusions template

جار الله (talkcontribs)

Hello how can i get transclusions template using Pywikibot core?

KlosseBot (talkcontribs)

When in write commonscat -start:Category:! -summary:Přidáno commonscat za použití bota it write this:

WARNING: CommonscatBot.__init__ set the property; this is only needed when the Bot accesses many sites.

Retrieving 50 pages from wikipedia:cs.

>>> Kategorie:'s-Hertogenbosch <<<

Commonscat template is already on Kategorie:'s-Hertogenbosch

WARNING: API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here

0 pages read

0 pages written

Execution time: 1 seconds

Script terminated by exception:

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


Traceback (most recent call last):

  File "/srv/paws/pwb/", line 263, in <module>

    if not main():

  File "/srv/paws/pwb/", line 257, in main

    run_python_file(filename, [filename] + args, argvu, file_package)

  File "/srv/paws/pwb/", line 121, in run_python_file


  File "/srv/paws/pwb/scripts/", line 549, in <module>


  File "/srv/paws/pwb/scripts/", line 541, in main

  File "/srv/paws/pwb/pywikibot/", line 1525, in run

    super(Bot, self).run()

  File "/srv/paws/pwb/pywikibot/", line 1434, in run


  File "/srv/paws/pwb/scripts/", line 254, in treat


  File "/srv/paws/pwb/scripts/", line 305, in addCommonscat


  File "/srv/paws/pwb/scripts/", line 453, in checkCommonscatLink

    commonsPage = pywikibot.Page(commonsSite, "Category:" + name)

  File "/srv/paws/pwb/pywikibot/tools/", line 1448, in wrapper

    return obj(*__args, **__kw)

  File "/srv/paws/pwb/pywikibot/", line 2179, in __init__

    super(Page, self).__init__(source, title, ns)

  File "/srv/paws/pwb/pywikibot/", line 163, in __init__

    self._link = Link(title, source=source, defaultNamespace=ns)

  File "/srv/paws/pwb/pywikibot/", line 5086, in __init__

    self._defaultns = self._source.namespaces[defaultNamespace]

  File "/srv/paws/pwb/pywikibot/", line 1014, in namespaces

    self._namespaces = NamespacesDict(self._build_namespaces())

  File "/srv/paws/pwb/pywikibot/", line 2612, in _build_namespaces

    is_mw114 = MediaWikiVersion(self.version()) >= MediaWikiVersion('1.14')

  File "/srv/paws/pwb/pywikibot/", line 2725, in version

    version = self.siteinfo.get('generator', expiry=1).split(' ')[1]

  File "/srv/paws/pwb/pywikibot/", line 1676, in get

    preloaded = self._get_general(key, expiry)

  File "/srv/paws/pwb/pywikibot/", line 1622, in _get_general

    default_info = self._get_siteinfo(props, expiry)

  File "/srv/paws/pwb/pywikibot/", line 1548, in _get_siteinfo

    data = request.submit()

  File "/srv/paws/pwb/pywikibot/data/", line 2342, in submit

    self._data = super(CachedRequest, self).submit()

  File "/srv/paws/pwb/pywikibot/data/", line 2175, in submit

    % (, info))

pywikibot.exceptions.NoUsername: Failed OAuth authentication for commons:commons: The authorization headers in your request are for a user that

does not exist here

<class 'pywikibot.exceptions.NoUsername'>

CRITICAL: Closing network session.

Xqt (talkcontribs)

Seems the bot user does not exists.

KlosseBot (talkcontribs)

But i login with this username.

Framawiki (talkcontribs)

With what account do you use this script ? KlosseBot ?

Framawiki (talkcontribs)

It's probably phab:T136114.

KlosseBot (talkcontribs)

Yes i use KlosseBot

Reply to "PAWS commonscat error"
Aschroet (talkcontribs)

Is there any script i can use to replace the whole wiki text of a page? I only found which replaces a list of words or which can add texts to the existing one. Has somebody a hint for me?

Xqt (talkcontribs) could do it: replace -regex ".*" "Any text you want to have on this page" -page:user:Aschroet/sandbox

Xqt (talkcontribs)

Better use: replace -regex "(?s).+" "Any text you want to have on this page" -page:user:Aschroet/sandbox

Aschroet (talkcontribs)

Thank you. A batch replacement is not possible, or?

Xqt (talkcontribs)

For small text you may use -pairsfile. Another ideas is using fixes. You have to modify your for replacement.

I think the best script would be using; refer -help for mor Information about that.

Reply to "Replace the whole text"
ChongDae (talkcontribs)

I'm porting my script from trunk to rewrite branch. How can I create item in wikidata?

Legoktm (talkcontribs)
import pywikibot
site = pywikibot.Site('en', 'wikipedia')
repo = site.data_repository()

data = {'sitelinks': {'site':'enwiki', 'title':'Main Page'}}
something = repo.editEntity({}, data, bot=True)
print something

It is in the roadmap to make this an ItemPage constructor in the future.

Edoderoo (talkcontribs)

thanks... been looking a while for this!

Reply to "createitem in rewrite branch"