Manual:Pywikibot/Compat/Installation

python version
Python version 2.7.2 or higher is strictly recommended for Wikimedia projects using the Compat branch.

Two versions of pywikibot
There are two branches under active development. You can choose between:


 * Core (formerly rewrite), which should be your first choice. If you don't know what to choose, take this branch.


 * Compat (formerly trunk) is an older version of the framework that is not actively maintained. There are limit scenarios where it might still be useful.  Compat was able to edit on MediaWiki 1.13 and earlier, even before MediaWiki had an API, and it includes a few scripts that are not available on core yet (see the 1>Special:MyLanguage/Manual:Pywikibot/Compat/Scripts|compatibility list).  However, if are going to edit WikiMedia wikis, man>Special:MyLanguage/Manual:Pywikibot/Compat/deprecation|compat is deprecated.

Download Pywikibot with Git

 * For compat (formerly "trunk") :

SVN

 * For compat (formerly trunk) :

To update the code for compat branch:

Dependencies
The pywikibot framework is quite a big and complex code and some scripts needs external python modules (libraries) from other sources also in order to work properly. The dependencies can be installed manually or automatically (not supported by core yet). If any issues arise during installation (of dependencies) please file a bug report or write to the pywikipedia-l maillist.

Automatic (recommended)
If available this is the recommended way, because this will result in an identical setup on all machines. All you have to do is just execute your favorite script after installation (for example, ) and pywikibot will ask you whether you want to install missing packages, and continue to ask questions on how you want to configure your local copy. Packages will be installed from OS package management if possible (all Linux, not under win). If they cannot be found they will be downloaded as archive from original source, extracted and installed. In the course of this process a few packages have to be slightly modified in order to work seamlessly with pywikibot. This modification needs an additional binary tool called patch (patch.exe under win). Unfortunately this is not available from MS; however, we can use a port of the original linux code ([http://gnuwin32.sourceforge.net/packages/patch.htm gnuwin32 patch.exe])

It is worth mentioning here that - despite the OS package management "install mode" - all files are installed locally into the  directory of pywikibot. This is a very useful feature for users that do not have permission to install software to their system, e.g. non-admins.

Manual (for experts)
In order to install the needed packages manually, you first need to know which ones. A full list of all needed modules can be found in [https://phabricator.wikimedia.org/diffusion/PWBO/browse/master/externals/__init__.py;553235e6fadaa27427b295bfa531b5904ad38f1a externals/__init__.py] and contains:


 * framework core code:
 * i18n [git submodule]
 * spelling [git submodule]
 * httplib2 [git submodule]
 * BeautifulSoup.py [included since important]
 * patch.exe
 * depending of which script will be used:
 * opencv, opencv/haarcascades [git submodule]
 * pycolorname [git submodule]
 * irclib
 * mwparserfromhell
 * parse-crontab
 * odfpy
 * openpyxl
 * python-colormath
 * jseg, jseg/jpeg-6b
 * mlpy
 * music21
 * ocropus
 * pydmtx
 * py_w3c
 * zbar
 * (slic)
 * (bob, xbob_flandmark)

Which ones you really need, depends strongly on the script you intend to run - if you are unsure use the automatic mode above. In order to check correct installation just run a bot script. If the dependencies are satisfied everything will be ok, else the framework will complain and ask whether it should install missing packages automatically.


 * For compat release (formerly trunk) :


 * 1) Right-click on your prefered directory and execute


 * 1) Choose   and paste the URL


 * 1) Choose   and change the default directory which is   e.g. to   if you like.


 * 1) 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 in a similar way as in core release.

compat
Do:

$ git clone --recursive https://gerrit.wikimedia.org/r/pywikibot/compat.git pywikibot-compat

Now, as similarly described in the core section above, you have to setup pywikibot. Choose any one of the following processes to configure your system:


 * Execute


 * Run your favorite bot script (e.g. ) since you are doing this in a fresh clone, it will trigger a bunch of questions on how you want to configure your local copy, answer them carefully in order to proceed.


 * If you already have a config file(s) from a previous version, you can copy those existing files into the right places (e.g. pywikibot-compat/).

See this article for more details on configuring your bot including creating the files manually. You may setup all externals manually if you want - but this is not needed in compat, confer Manual:Pywikipediabot/Installation for further info. You will also have to enter the password for your bot eventually. Now you have finished the configuration of compat and can continue setting up the webspace and jobs to execute.