The PyPI package for pywikibot has various issues that make it unusable. The first one is that the "requests" package is not listed as a dependency, so it needs to be installed manually.
virtualenv venv source venv/bin/activate pip install pywikibot python -c "import pywikibot" # fails because "requests" is not installed pip install requests python -c "import pywikibot" # succeeds
The second is that it cannot be used to perform any edit because issue T142155 was still not fixed when the package was created. To reproduce this bug, just run the following script in the virtualenv set up as above, with an appropriate user-config.py:
import pywikibot site = pywikibot.Site() site.login()
which gives the following output:
Password for user Pintoch on wikipedia:en (no characters will be shown): Logging in to wikipedia:en as Pintoch WARNING: API warning (login): Fetching a token via "action=login" is deprecated. Use "action=query&meta=tokens&type=login" instead. WARNING: API warning (login): Main-account login via "action=login" is deprecated and may stop working without warning. To continue login with "action=login", see [[Special:BotPasswords]]. To safely continue using main-account login, see "action=clientlogin". Traceback (most recent call last): File "test.py", line 3, in <module> site.login() File "/home/antonin/Programmation/Wikipedia/pywikibot/pywikibot/site.py", line 2004, in login if loginMan.login(retry=True): File "/home/antonin/Programmation/Wikipedia/pywikibot/pywikibot/login.py", line 277, in login cookiedata = self.getCookie() File "/home/antonin/Programmation/Wikipedia/pywikibot/pywikibot/data/api.py", line 3007, in getCookie prefix = login_result['login']['cookieprefix'] KeyError: u'cookieprefix' <type 'exceptions.KeyError'> CRITICAL: Closing network session.