No user_config.py

Viewed 616

We have an internal wiki and I want to use pywikibot to get some data from it. Installed it from pip but when I import it I get:

>>> import pywikibot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pywikibot/__init__.py",
line 25, in <module>
from pywikibot.bot import (
  File "/usr/local/lib/python3.7/site-packages/pywikibot/bot.py", line
105, in <module>
    from pywikibot import config2 as config
  File "/usr/local/lib/python3.7/site-packages/pywikibot/config2.py",
line 373, in <module>
    base_dir = get_base_dir()
  File "/usr/local/lib/python3.7/site-packages/pywikibot/config2.py",
line 367, in get_base_dir
    raise RuntimeError(exc_text)

RuntimeError: No user-config.py found in directory '/vagrant'.

Looking here https://www.mediawiki.org/wiki/Manual:Pywikibot/Installation#Configure_Pywikibot

I see a reference to pwb.py, but that does not exist in /usr/local/lib/python3.7/site-packages/pywikibot.

What am I missing here?

Thanks!

2 Answers

Installing pywikibot from pip currently only installs the library part. The pwb.py and related console scripts are not included in the PyPI package. That means that you'll need to create the user-config.py manually or download the scripts in some other way. I believe most pywikibot users just clone the git repo. The general process would be something like this:

git clone https://github.com/wikimedia/pywikibot.git --depth 1
python3 -m pip install -U setuptools
python3 -m pip install -e pywikibot/
cd pywikibot/
python3 pwb.py generate_family_file.py https://url.to.your/wiki/api.php? mywikiname
python3 pwb.py generate_user_files.py
# follow the prompts
Related