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.

Summary by Dvorapa

Everybody can use pywikibot, but please be careful to local community restrictions

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.

Summary by Dvorapa

The combination of and can effectively move pages and update redirects. There is currently no script, which could do both actions at once

Jc86035 (talkcontribs)

Does update redirects as well to avoid creating double redirects?

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

Currently not.

Jc86035 (talkcontribs)

Are there any scripts which do so?

XXN (talkcontribs)

Pagegenerator in different language.

Summary by Dvorapa

Pagegenerator for the Czech Wikipedia is -family:wikipedia -lang:cs

Walter Klosse (talkcontribs)

How i make pagegenerator for category on wikipedia in czech language?

Framawiki (talkcontribs)

Hello, do you want something like

python replace "1" "2" -lang:cz -category:test


Dvorapa (talkcontribs)

correct is -lang:cs

Replacing template with text

Summary by Dvorapa

To work with templates there is a script. It can easily get e.g. category of templates to process by -cat parameter (talkcontribs)


I need a script that:

1) Select pages that are in a specific category

2) Delete in those pages an old template with its parameters (that could also be sub-templates); the template is the same, but the content is different for all, so I can't specify manually the text

3) And replace it with a text (a new template with standard content for all)

It's possible? I see something in '''' (point 1 and 3), but I'm not sure it can do the 2nd; and it seems that '''' can only replace the template name.


Xqt (talkcontribs)

Try script.

Glz19 (talkcontribs)

Thank you for the answer. It's possible with it selecting a category, for work only on pages in it? I read the documentation page but I can't see it.

Xqt (talkcontribs)

All scripts have a documentation with it. Just use -help option. In your case -cat:<categoryname> should do it.

How to disable "Sleeping for N seconds" on PyWikiBot

Summary by Dvorapa

Sleeping for N seconds should not be disabled as it makes load to servers (talkcontribs)

How to disable "Sleeping for N seconds" on PyWikiBot

Xqt (talkcontribs)

You shouldn't. This is necessary to throttle writing to the site high frequently and it is restricted on most wiki's.

Framawiki (talkcontribs)

Why you want to disable a security ? Not a good idea I think :) (talkcontribs)


I'm new to pywikibot and am stuck on getting a login failed (aborted) message.

When I try to use with the argument "double" and am prompted for what action to take, whenever I choose to "accept changes" I get that the Login failed(aborted) even when I manually input the bot password.

The login works for other scripts such as pagefromfile or just simply using the script.

Thanks for the help

Framawiki (talkcontribs)

Hello, can you copy/paste the full shell history somewhere, like on ? (talkcontribs)

Thanks for the help,

here is the shell history after I ran the command.

The wikibot is initially able to login, but after it wants to make the first change it prompts the user for the password (The login will fail even with the right password).

Reply to " Login Failed (Aborted)"

removing references from wikidata doesn't work

Summary by Soued031

false alarm

Soued031 (talkcontribs)

Hello, I found a bug in pywikibot but I am not sure if I use the method correctly. Deleting a reference does not seem to work. I'm using the last version from git. If you want I have a fix, but since I cannot find any documentation about pywikibot or an explanation of how a method should be written the fix seems out of place. Link with diff and the code that I'm right now using to modify wikidata:

Matěj Suchánek (talkcontribs)

The docstring of Claim.removeSources says: @type sources: list of pywikibot.Claim, which['P1082'][i].sources is not. That is a list of key: list of pywikibot.Claim mappings.

Soued031 (talkcontribs)

Thanks for you answer! So how does the code need to be changed as I haven't seen any example of removeSource(s)?I mean I understand that the type is wrong but how do I achieve the "right" type?

Matěj Suchánek (talkcontribs)

I hope this will work (it should remove all references attached to a statement):

sources = []
for source in claim.sources:
    for value in source.values():
Soued031 (talkcontribs)

Thanks a lot your code snippet works!

Soued031 (talkcontribs)


I've written a script whose goal is to write the population for (only at the moment) per year, which can be found here: When running the script I actually get 3 Warnings;

WARNING: /home/edson/Bureau/core/pywikibot/ _NotImplementedWarning: claim without on_item set is deprecated.

  return fn(self, *args, **kwargs)

WARNING: /home/edson/Bureau/core/pywikibot/ UserWarning: Neither claim.on_item nor baserevid provided

  return fn(self, *args, **kwargs)

WARNING: API error noclaim: The "claim" parameter must be set.

Traceback (most recent call last):

  File "", line 263, in <module>

   if not main():

  File "", line 256, in main

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

  File "", line 120, in run_python_file


  File "./", line 38, in <module>


  File "/home/edson/Bureau/core/pywikibot/", line 5002, in addQualifier

   data = self.repo.editQualifier(self, qualifier, **kwargs)

  File "/home/edson/Bureau/core/pywikibot/", line 1331, in callee

   return fn(self, *args, **kwargs)

  File "/home/edson/Bureau/core/pywikibot/", line 7813, in editQualifier

   data = req.submit()

  File "/home/edson/Bureau/core/pywikibot/data/", line 2195, in submit

   raise APIError(**result['error']) noclaim: The "claim" parameter must be set. [help:See for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;; for notice of API deprecations and breaking changes.]

<class ''>

CRITICAL: Closing network session.

What am I doing wrong?

Dvorapa (talkcontribs)

@Matěj Suchánek

Matěj Suchánek (talkcontribs)

How does your code look like?

Soued031 (talkcontribs)

@Matěj Suchánek It's on the google drive link mentioned above

Matěj Suchánek (talkcontribs)

Oops, I see now.

The solution is to move the bottom line (item.addClaim) just before # add qualifier to claim.

Soued031 (talkcontribs)

@Matěj Suchánek Great it works! Thanks for the fast answer. Do I need to do something special to ask for bot rights?

Matěj Suchánek (talkcontribs)

If you want to run a bot on Wikidata, I strongly recommend you requesting the flag at d:WD:RFBOT.

Soued031 (talkcontribs)

Thanks I will look at it. (talkcontribs)

When I try to create a webpage on a 3rd party wiki using the pagefromfile script, it required me to log into my bot account a second time despite being already logged in (I used the python login -sysop command prior),

The bot also has the proper rights to write/read a page on the wiki.

The page will properly post once I manually put in the bot password but if possible I would like to automate the process so that it does not require any input after calling the Pagefromfile function.

The paramters I am currently using are -file, -begin, -end, -notitle, -force.

The bot can use other functions such as weblinkchecker without requesting me to log in a second time

Reply to "Pagefromfile requires additional login"

(Solved) ERROR: URLError: <urlopen error [Errno 11001] getaddrinfo failed>

TheMobius (talkcontribs)

Hello, I am consistently getting this error, and not just with

C:\Documents and Settings\(me)\Desktop\pywikipedia> add -links:"C
loth Armor"
Category to add (do not give namespace): Items
No handlers could be found for logger "pywiki"
Getting 60 pages from requiem_wiki:en...
ERROR: URLError: <urlopen error [Errno 11001] getaddrinfo failed>
WARNING: Could not open 'http://requiem.irowiki.orgNone/index.php?title=Special:
Export&useskin=monobook'. Maybe the server or
 your connection is down. Retrying in 1 minutes...

Basically, I have no Idea what to fix. I'm just trying to add a category to all the links found on a specific page. Any help is more than appreciated, Thank you very much.

TheMobius (talkcontribs)

Solved, played around with for a good amount of time. Ended up being a simple issue that I kept overlooking.

   def scriptpath(self, code):
       return '/w/'

I didn't have "/w/" set properly.