Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No user_config.py

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!

like image 876
Larry Martell Avatar asked Apr 28 '26 09:04

Larry Martell


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
like image 64
AXO Avatar answered May 01 '26 00:05

AXO


Adding generate_family_file is in active development: https://gerrit.wikimedia.org/r/c/pywikibot/core/+/634544

The other two script will follow later I guess.

like image 36
xqt Avatar answered May 01 '26 00:05

xqt