Manual:Pywikibot/2.0/login.py
Appearance
< Manual:Pywikibot | 2.0
This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on the information here being up-to-date. |
The script included in scripts/login.py
occasionally fails silently. Until that is fixed, the following workaround can help:
This sets the PYWIKIBOT2_DIR environment variable before importing pywikibot.
import os
os.environ['PYWIKIBOT2_DIR'] = '/dir/that/contains/user-config.py/'
import pywikibot
site = pywikibot.Site()
if not site.logged_in():
site.login() # If you've never logged in before, it may prompt you for a password