From Wikibooks, open books for an open world
Jump to: navigation, search

This is a complete step-by-step guide on how to run your own pywikibot on Wikimedia projects, from your Mac, hopefully more easy and readable than the original one.


Downloading MacPython[edit]

Apple provides an installation of Python with every Mac OS X installation, by default. You don’t need to install Python, but you might want to update it. Here are the instructions.

First of all, you need to download Python, the application that reads the scripts and does something with them. Download MacPython from here, choosing “Python 2.5.2 for Macintosh OS X”. Open the downloaded dmg file and install it. In Applications in Finder you should now find a folder named “MacPython 2.5”. Nothing else needs to be done here, close Finder.

NOTE: A new application will be installed on your Mac, with the name “IDLE”. It’s just difficult and confusing, and nothing worth spending time on trying to use.

Downloading SVN[edit]

Many Wikimedia projects require that you always should run the latest version of the Pywikipedia framework. The easiest option is to use SVN. This is no harder than running the bot itself.

If you are using 10.5 or below, download “My Subversion-1.5.5 Package” from this page. Open the Subversion-1.5.5 package, and complete the installation. Now, everything is all set to download the scripts.

Downloading the scripts[edit]

Open Terminal, you can find it by searching for it in Spotlight. Now, copy-paste the following into Terminal, and press enter/return:

svn checkout pywikipedia

A folder will be created in the “home” folder (look in the left column in the Finder for the house icon and your username), with the name “pywikipedia”, in which all the scripts will be when the downloading is finished. You can see when it’s finished by looking for the following in the last line in Terminal:


This text is equal to the one appearing when you open Terminal (it is called prompt).


You need to configure your bot before you can use it. For this purpose we’ll use pico, a simple and straight TUI text editor. Go in Terminal and cd to your pywikipedia directory, e.g.:

cd pywikipedia

Then type pico Follow the instructions below; when you’re done press CTRL-O to write the file on disk and CTRL-X to quit the editor.


mylang = 'xx'

“xx” is the main language you want your bot to work on, equivalent to the language code of the Wikimedia project in which the bot’s going to run.


If the bot’s main wiki is Wikipedia, go right to the Username(s) section. If the bot’s main wiki is for instance Wikibooks, add this line to

family = 'wikibooks'

NOTE: Running bots on Wiktionary is more complicated than on the other projects, and is not recommended for beginners. This will not be described further in this guide. If you’re running your bot on Commons, both mylang and family are to be set to “commons”.


Now, you’ll define the desired username(s) of the bot. Don’t register the bot on the wikis yet. You can do this by using the following:

usernames['FAMILY']['MYLANG'] = u'ExampleBot'

“MYLANG” is the same as you defined in the mylang option, and the same with “FAMILY”. If you’re running the bot on Wikipedia, the family option is not defined, but should be “wikipedia” in the above line (se examples below). The line can be defined as many times as you like (only one per wiki), for each of your bots on different WM wikis. The default will be what’s defined in mylang, except when running interwiki; the bot will edit on all the wikis defined in


It’s recommended that you change the encoding to UTF-8. Especially if you are editing a wiki with non-ASCII characters, this is important, if you don’t change the encoding, you’ll end up with “?”s all over the place. For example, the Spanish name María will render like Mar?a. Add this line to

console_encoding = 'utf-8'

API login[edit]

Because of some problems with SUL bots, the bot must log in via API. Add this line to

use_api_login = True

Now, by using Save as, save the file in the “pywikipedia” folder. Then, close TextEdit. examples[edit]

EksempelBot on no.wikipedia[edit]

mylang = 'no'
usernames['wikipedia']['no'] = u'EksempelBot'

console_encoding = 'utf-8'
use_api_login = True

ExampleBot on Commons[edit]

mylang = 'commons'
family = 'commons'
usernames['commons']['commons'] = u'ExampleBot'

console_encoding = 'utf-8'
use_api_login = True

BeispielBot on de.wikipedia and de.wikibooks, with de.wikipedia as main wiki[edit]

mylang = 'de'
usernames['wikipedia']['de'] = u'BeispielBot'
usernames['wikibooks']['de'] = u'BeispielBot'

console_encoding = 'utf-8'
use_api_login = True

Registering the username on the wanted wikis[edit]

It is recommended that you are registered on the wikis where you want to run your bot. Then, when you’re logged into your own user account, write “Special:Userlogin” in the search box, then, choose to register an account. Now fill out the required fields on the page and continue. If the account creation is successful, you should now be able to run the bot.

With SUL it’s easy to run bots on several wikis. If you’ve created the bot account recently, the account is already merged.

If you created it some time ago and it’s not merged, or if it was created some time ago on other wikis, you’ll have to merge it in Special:MergeAccount. Now, when logging in, the other accounts will automatically be registered as you enter the same password for all wikis.

Bot flag and test edits[edit]

Don’t forget to apply for bot flag/permission to run the bot! On en.wikipedia and he.wikipedia (there may be more), you have to apply before you make test edits. On other wikis you can apply and make test edits right away. When you make test edits, use the argument -pt:15, which tells the bot to wait 15 seconds between each edit (4 edits/min), so the recent changes list doesn’t get flooded with the bot’s edits.


Navigating to the right folder[edit]

To run the scripts, you first need to navigate to the folder in which the scripts are. Write the following in Terminal:

cd /Users/USER_NAME/pywikipedia

“USER_NAME” is the home text to the right of the house icon in Finder.


The above can be unnecessarily boring to write each time you want to use the bot. Terminal saves every command you use, and you can use old commands by pressing arrow up. With one press on the arrow up button, you see the last command used. Most likely, the command you see is not the right one; simply keep pressing arrow up until you see the right one. Then, press enter/return. Now, you can start running the bot. When you’re running a script followed by another when the first one is done, you don’t have to use the navigation command once again; only if you close Terminal.

Logging in[edit]

Now, you need to log into the bot accounts on the wiki(s), by typing the following into Terminal:


Terminal will ask for the password. Type the password you used when you registered the bot’s username.

If you have accounts on multiple wikis, use -all

Type in the passwords, as above.

Logging in is only necessary once, the bot stays logged in.

Running the scripts[edit]

After navigating to the right folder, you can now select scripts, by writing:


To see an overview of some scripts with description pages, look here.


Arguments are written by using a dash: - and then the name of the argument, -pt:15 for instance. Many scripts require arguments, for example

python -start:! -autonomous

As default, the bot will run interwiki from the main language and project, and correct them on all registered wikis. The -start and -autonomous arguments says that it’ll check all pages on the wiki and add/modify interwikis. It will not remove anything, and it will give up when discovering conflicts, see

Global arguments[edit]

All scripts recognize the following arguments:

Shows the script’s help text
Selects the language you want to work on. Overrides the mylang option in user-config.
Selects the family you want to work on. Overrides the family option in user-config.
Enable the logfile. Logs will be stored in the logs subdirectory.
Enable the logfile, using “xyz” as the filename.
Disable the logfile (if it's enabled by default).
-putthrottle:nn or short -pt:nn
Set the minimum time (in seconds) the bot will wait between saving pages. The default value is zero.



To update your scripts, simply write the following into Terminal:

svn update pywikipedia

When it’s done, it will say “At revision XXXX” (“XXXX” depending on the latest revision). If you have modified some of the scripts, don’t worry, your modifications will be merged with the changes made by updating.

If you have experience using Automator, you can do the Shell process in a workflow and save it to your desktop or on your dock, so you can reach it more easily. It’s a good idea to secondary click on it, then, while pressing Alt/Option, hold the cursor over Always open in, then choose Automator runner.


You might want to go through the script text before you run it, because for some languages the script may be bot specific. Secondary-click on it, hold the cursor on Open in, then choose Other, scroll down and double-click on TextEdit. However, this is not mandatory, and not recommended for beginners, but if you have to; be careful when editing the scripts!


If you want to revert your changes to a script, simply run the following:

svn revert

If a script suddenly doesn’t work, and produces the output SyntaxError: invalid syntax, you have encountered an SVN conflict.

Revert the script as described above. Then try to run it. If it works, run the following in Terminal:

svn resolved

You can now try to make the same edits again, if desired.