Manual:Pywikibot/Installation

Initial setup
There are four basic steps to installing pywikibot:
 * 1) Download or update Python,
 * 2) Download pywikibot,
 * 3) Configure pywikibot's basic settings.

Downloading Python

 * Unix systems: typically have a recent-enough version of Python installed. Check with.


 * Mac OS X 10.8+: has a version of Python that is recent enough to run pywikibot. If you run an older OS X, or are unsure, download and install Python 2.7.10 from http://www.python.org/downloads/


 * Windows: download and install the latest release Python 2.7.10 from http://www.python.org/downloads/


 * Python version: The following versions of Python are supported:

Due to a Unicode bug in the underlying python library, Python 2.7.0 and 2.7.1 are not supported using the Core branch. See also the requirements for a bot, which describes needed python version and pywikibot branches.

Download Pywikibot
The easiest way to download Pywikibot is to use [http://tools.wmflabs.org/pywikibot/ the latest nightly release]. Just download the pywikibot zip file to your computer and decompress the file – there is no further installation required.

Download Pywikibot with Git
For installing with Git you need to run:

With the  option it automatically installs the required submodules. Currently there are two submodules (i18n and spelling); one of them (i18n) is really required even for English language bots:

Download Pywikibot with SVN
If you don't want to use Git you can still use SVN.

Windows users may use the GUI extension TortoiseSVN, see next section below.

For installing with SVN you should run

Download Pywikibot with TortoiseSVN for Windows user
TortoiseSVN is a Windows shell extension with GUI working as SVN client. You may download the current release at http://tortoisesvn.net/downloads.html.

If you like using TortoiseSVN you may use it as follows:


 * 1) Right-click on your preferred directory and execute
 * 2) Choose   and paste the URL
 * 3) Choose   and change the default directory which is   e.g. to   if you like.
 * 4) Confirm with
 * Now we have to install external libraries used by the framework. There are different ways to do that e.g. again with the checkout command. Another way is using properties. You may set it manually but it is very easy to use the preference file named .svnprops coming with the framework which sets all the needed properties:


 * 1) Right-click your working directory
 * 2) Select the last item in the drop list which might be folder's
 * 3) Select   tab and click on   button
 * 4) click   and select the file   in your framework folder
 * 5) Confirm with   for property settings
 * 6) Confirm with   for folder properties
 * 7) Now right-click onto your working copy and select   to download the external libraries.

Right-click on your working copy and choose
 * Updating the working copy

Shortcut in command line
To allow your source code to be developed outside of the pywikibot source directory, add something like:

to a file that gets run on login, usually ~/.bashrc - this avoids typing the export PYTHONPATH part in each time you log in. Naturally, change paths to match your installation.

Similarly, you can set the PYWIKIBOT_DIR environment variable to specify the directory in which user-specific information is stored (in particular, user-config.py which contains login data for the bot).

Updating
The pywikibot framework is a perpetual beta software. Bugfixes, new options, new behavior and changes of the mediawiki software leads to frequently new releases and needs the working copy code to be up to date. Please update your branch regularly (daily period or at least once a week).

Updating nightly dump

 * If you are using a nightly version, the process is a bit more complicated. You have to re-download a full copy from [http://tools.wmflabs.org/pywikibot/ here]. Before installing it, backup your configuration files and scripts (user-config.py, any family file, or custom script that you might have created, and any current dump XML file you're using for a wiki). Replace your pywikibot directory by the new version you just downloaded. Restore your configuration files. If you're not sure of what you're doing, do not erase but keep a backup of your complete old pywikibot directory, to avoid losing any important files.

Updating git

 * If you used Git for downloading Pywikibot, you must go to the your directory and run the following command:
 *  


 * You may need to do   as well, if you need up-to-date i18n files.

Automatic updating git on Wikimedia Labs
For automatic updating you can make update bash file and put it in root and fill it with these commands, For WMF labs (in your service group):

and then run crontab -e and enter the following to make your bot to run every day at 00:00AM (midnight):

Notice: in these cods yourservicegroup is name of your service group (without "-local").

Updating with TortoiseSVN (for Windows user)
Updating the working copy with TortoiseSVN is just easy: Right-click on your working copy directory and choose

Dependencies
Use  package management system to install dependencies.

It is included by Python 2.7.9 and Python 3.4. To install all dependencies just run the following command:

For a single package use:

To uninstall a single package use:

Creating user files
As a final step before using the bot scripts, you have to create user configuration files. The main one is. If you execute your favorite script after installation (for example, ) then pywikibot ask questions on how you want to configure your local copy and will create these files. You can also run generate user files.py to create these files.

Running Pywikibot under Windows
Please notice the instruction at Manual:Pywikibot/Windows.

Verifying your installation
With the core branch, entering in the command line python pwb.py login should prompt for the login password for your bot, and then report Logged in on somewiki:lang as bot username.