Manual:Pywikibot/user-config.py

Configuration
Before you run any of the programs, you need to create a file named user-config.py in your pywikibot directory (or pywikipedia if you are using pywikibot in compat mode). You create it in either of two ways:
 * 1) Create the file manually.  It needs at least two or three variables configured, and placed in the correct location.
 * 2) Run the script generate_user_files.py by entering python pwb.py generate_user_files.py in a command shell, which will interactively generate the file in an interactive "wizard" style, and store it in the default configuration location.

Location
Pywikibot looks for user-config.py in the following locations, in order:
 * Specified via the  argument (for example:  )
 * The content of the environment variable PYWIKIBOT2_DIR (core)/PYWIKIBOT_DIR (compat)
 * The directory in which the pwb.py file is
 * In core it checks the .pywikibot</tt> directory in the application data directory (Windows) or home directory (that directory gets automatically created)
 * In compat it checks the directory in which the wikipediatools</tt> is located

(See also: and .)

Below are instructions for manually editing this file.

For Wikimedia projects
Open a text editor (e.g. Notepad in Windows) and save the text file as user-config.py</tt> in the pywikipedia</tt> folder.

If your language uses non-ASCII characters, you should use a Unicode-aware editor such as Notepad++ and save your user-config with Unicode encoding without BOM marks. Don't forget to insert as the first line.

Add the following lines to :

Now save  again.

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

console_encoding = 'utf-8' use_api_login = True

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

console_encoding = 'utf-8' use_api_login = True

ExampleBot on Wikidata
mylang = 'wikidata' family = 'wikidata' usernames['wikidata']['wikidata'] = u'ExampleBot'

console_encoding = 'utf-8' use_api_login = True

ExampleBot on Test
mylang = 'test' family = 'test' usernames['test']['test'] = u'ExampleBot'

console_encoding = 'utf-8' use_api_login = True

BeispielBot on de.wikipedia and de.wikibooks, with de.wikipedia as main wiki
mylang = 'de' usernames['wikipedia']['de'] = u'BeispielBot' usernames['wikibooks']['de'] = u'BeispielBot'

console_encoding = 'utf-8' use_api_login = True

For non-Wikimedia wikis

 * Main Page: Manual:Pywikibot/Use on third-party wikis