Manual talk:Pywikibot/

The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of (even if they share the same username).

-remove doesn't remove[edit]

Running -remove template_name gives me a bunch of results like:

No changes were necessary in [[Help:Copying]]

Any idea why it won't remove the template? --w:User:Naught101 00:54, 30 June 2008 (UTC)Reply[reply]

Syntax? Maybe run it -remove "templatename" Do You have the newest version, have You visited #pywikipediabot connect (they are quite helpful there). Best regards, --birdy geimfyglið (:> )=| 11:12, 30 June 2008 (UTC)Reply[reply]

New entry for regex matches[edit]

When there is a space between {{Template: and the template being replaced, i.e.

{{template: User moxie}}

cf.xeno (talk) 15:36, 22 April 2009 (UTC)Reply[reply]

no results when template exists (solved)[edit]

I have the page:

And get the result:

C:\Users\t\Desktop\pywikipedia> "Cement Saw" "Cement Saw test"
unicode test: triggers problem #3081100
Getting references to [[Template:Cement Saw]] via API...
0 pages were changed.

Is this a problem with the family file? Can I get a result of what page pywikipedia is pulling from? I suspect it is pulling from the wrong pages.

thank you for your time. Adamtheclown 05:50, 18 November 2010 (UTC)Reply[reply]

C:\Users\t\Desktop\pywikipedia> "TOCright" "TOCright test"
unicode test: triggers problem #3081100
Getting references to [[Template:TOCright]] via API...
Getting 3 pages from dead:en...
Traceback (most recent call last):
  File "C:\Users\t\Desktop\pywikipedia\", line 1268, in __iter_
    for loaded_page in self.preload(somePages):
  File "C:\Users\t\Desktop\pywikipedia\", line 1287, in preload

    pywikibot.getall(site, pagesThisSite)
  File "C:\Users\t\Desktop\pywikipedia\", line 4322, in getall
    _GetAll(site, pages, throttle, force).run()
  File "C:\Users\t\Desktop\pywikipedia\", line 3955, in run
    data = self.getData()
  File "C:\Users\t\Desktop\pywikipedia\", line 4138, in getData
    response, data =, predata)
  File "C:\Users\t\Desktop\pywikipedia\", line 5164, in postForm
    cookies=self.cookies(sysop = sysop))
  File "C:\Users\t\Desktop\pywikipedia\", line 5215, in postData
    raise PageNotFound(u'Page %s could not be retrieved. Check your family file
?' % url)
PageNotFound: Page
pecial:Export&useskin=monobook could not be retrieved. Check your family file ?
useskin=monobook could not be retrieved. Check your family file ?
0 pages were changed.

It looks like the bot is pulling from the wrong page:

It is listing two index.php, not one. Maybe I should change my family file? Adamtheclown 08:34, 19 November 2010 (UTC)Reply[reply]

I figured it out by changing my family file:
# -*- coding: utf-8  -*-

import family

# The official Beta Wiki.
class Family(family.Family):

    def __init__(self):

        family.Family.__init__(self) = 'dead' #Set the family name; this should be the same as in the filename.

        self.langs = {
            'en': '', #Put the hostname here.

    def version(self, code):
        return "1.16.0"  #The MediaWiki version used. Not very important in most cases.

    def scriptpath(self, code):
        return '/w/' #The value of {{SCRIPTPATH}} on this wiki

    def apipath(self, code):
        return '/w/api.php' #The path of api.php

Problem solved. Adamtheclown 08:38, 19 November 2010 (UTC)Reply[reply]

Replace old template with its parameter[edit]

Hi, is there any command to replace old template with all its parameters to a new template? For example: {{bar|1}} to be replaced by {{--}}

When I use python scripts/ "bar" "--", it replaces {{bar|1}} with {{--|1}}

Thanks, 👦 Rachmat · t 09:51, 7 October 2015 (UTC)Reply[reply]

Remove template with summary provided[edit]

It was throwing the error:

Traceback (most recent call last):
  File ".\scripts\", line 369, in <module>
  File ".\scripts\", line 364, in main
    bot = TemplateRobot(preloadingGen, templates, **options)
  File ".\scripts\", line 225, in __init__
    builder = textlib._MultiTemplateMatchBuilder(site)
UnboundLocalError: local variable 'site' referenced before assignment

I made the following change and it fixed it:

        builder = textlib._MultiTemplateMatchBuilder(site)


        builder = textlib._MultiTemplateMatchBuilder(

-- Prod (talk) 19:28, 11 March 2016 (UTC)Reply[reply]

How to remove a template with parameter[edit]

I want to remove the Template "Tranlation" with parameter "st" (Translation|st),What should I do?SteveZihang (talk) 03:17, 24 January 2017 (UTC)Reply[reply]