Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no module named Pywikibot.config2 #22

Open
JB0linches opened this issue Mar 2, 2023 · 2 comments
Open

no module named Pywikibot.config2 #22

JB0linches opened this issue Mar 2, 2023 · 2 comments

Comments

@JB0linches
Copy link

Hello. I am trying to use this tool to update a wikibase deployed on localhost.
After following all the config steps, I get the following error when executing any of the import functions:

(venv) jorge@jorge-VirtualBox:~/TFM/WikibaseSync$ python import_one.py Q1
Traceback (most recent call last):
  File "/home/jorge/TFM/WikibaseSync/import_one.py", line 4, in <module>
    import pywikibot
  File "/home/jorge/TFM/venv/lib/python3.10/site-packages/pywikibot/__init__.py", line 21, in <module>
    from pywikibot import config as _config
  File "/home/jorge/TFM/venv/lib/python3.10/site-packages/pywikibot/config.py", line 991, in <module>
    exec(compile(f.read(), _filename, 'exec'), _exec_globals)
  File "/home/jorge/TFM/WikibaseSync/user-config.py", line 1, in <module>
    from pywikibot.config2 import usernames
ModuleNotFoundError: No module named 'pywikibot.config2'

I have installed all the requirements in requirements.txt

(venv) jorge@jorge-VirtualBox:~/TFM/WikibaseSync$ pip install -r requirements.txt
Requirement already satisfied: certifi==2019.11.28 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (2019.11.28)
Requirement already satisfied: chardet==3.0.4 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 2)) (3.0.4)
Requirement already satisfied: idna==2.8 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 3)) (2.8)
Requirement already satisfied: isodate==0.6.0 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 4)) (0.6.0)
Requirement already satisfied: pycparser==2.19 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 5)) (2.19)
Requirement already satisfied: pyparsing==2.4.5 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 6)) (2.4.5)
Requirement already satisfied: rdflib==4.2.2 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 7)) (4.2.2)
Requirement already satisfied: requests==2.22.0 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 8)) (2.22.0)
Requirement already satisfied: six==1.13.0 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 9)) (1.13.0)
Requirement already satisfied: SPARQLWrapper==1.8.4 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 10)) (1.8.4)
Requirement already satisfied: urllib3==1.25.7 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 11)) (1.25.7)
Requirement already satisfied: pywikibot~=7.7.2 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 13)) (7.7.3)
Requirement already satisfied: mwparserfromhell>=0.5.0 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from -r requirements.txt (line 14)) (0.6.4)
Requirement already satisfied: setuptools>=48.0.0 in /home/jorge/TFM/venv/lib/python3.10/site-packages (from pywikibot~=7.7.2->-r requirements.txt (line 13)) (67.4.0)

It seems pywikibot is correctly installed even though it says the module config2 does not exist.

Can it be that Im doing something wrong with the configuration? Im currently running a wikibase instance in docker with the following configuration:

wikibase URL = http://localhost:80
SPARQL Endpoint = http://localhost:8834/proxy/wdqs/bigdata/namespace/wdq/sparql
API= http://localhost:80/api.php
Entity URIs = http://wikibase.svc/entity

All my containers are running without any problems and all the endpoints and services are usable:

(venv) jorge@jorge-VirtualBox:~/TFM/WikibaseSync$ sudo docker ps
CONTAINER ID   IMAGE                                     COMMAND                   CREATED      STATUS       PORTS                                   NAMES
4fb0dd06cac1   wikibase/quickstatements:wmde.10          "/bin/bash /entrypoi…"    3 days ago   Up 2 hours   0.0.0.0:8840->80/tcp, :::8840->80/tcp   working_env_quickstatements_1
d1b23c74e911   wikibase/wdqs:0.3.118-wmde.10             "/entrypoint.sh /run…"    3 days ago   Up 2 hours                                           working_env_wdqs-updater_1
de9a077d1c86   wikibase/wdqs-frontend:wmde.10            "/entrypoint.sh ngin…"    3 days ago   Up 2 hours   0.0.0.0:8834->80/tcp, :::8834->80/tcp   working_env_wdqs-frontend_1
a9cdd8b8c652   wikibase/wikibase-bundle:1.38.5-wmde.10   "/bin/bash /entrypoi…"    3 days ago   Up 2 hours   0.0.0.0:80->80/tcp, :::80->80/tcp       working_env_wikibase_1
8ff217c9b2ec   wikibase/wikibase-bundle:1.38.5-wmde.10   "/bin/bash /jobrunne…"    3 days ago   Up 2 hours   80/tcp                                  working_env_wikibase_jobrunner_1
f214a98619f2   wikibase/wdqs-proxy:wmde.10               "/bin/sh -c \"/entryp…"   3 days ago   Up 2 hours   80/tcp                                  working_env_wdqs-proxy_1
dd918bea43a3   mariadb:10.9                              "docker-entrypoint.s…"    3 days ago   Up 2 hours   3306/tcp                                working_env_mysql_1
2428b98a8f6a   wikibase/elasticsearch:6.8.23-wmde.10     "/usr/local/bin/dock…"    3 days ago   Up 2 hours   9200/tcp, 9300/tcp                      working_env_elasticsearch_1
d3e6eb687545   wikibase/wdqs:0.3.118-wmde.10             "/entrypoint.sh /run…"    3 days ago   Up 2 hours   9999/tcp                                working_env_wdqs_1

In the application.config.ini I have:

user = admin
sparqlEndPoint = http://localhost:8834/proxy/wdqs/bigdata/namespace/wdq/sparql
domain = localhost:80
protocol = http
apiUrl= http://localhost:80/api.php
entityUri=http://wikibase.svc/entity
propertyUri=http://wikibase.svc/prop
overwriteLocalChanges = false

In the user-config.py, which is whereI seem to have the problem, I have:

from pywikibot.config2 import usernames

user_families_paths = ['./config']
mylang = "wikidata"
family = "wikidata"
usernames['my']['my'] = u'admin'
password_file = "user-password.py"
minthrottle = 0
maxthrottle = 0
max_retries = 100

And finally my user-password.py looks something like this

(u'admin', BotPassword(u'WikibaseUpdater', u'<the random letters and numbers you get when you create the bot on special pages>'))

Thank you very much

@D063520
Copy link
Contributor

D063520 commented Mar 2, 2023

can you try to replace:

"from pywikibot.config2 import usernames"

with

"from pywikibot.config import usernames"

?

@JB0linches
Copy link
Author

Hi

I already tried that before posting the issue.
I still have an error with the change, but this is the output:

(venv) jorge@jorge-VirtualBox:~/TFM/WikibaseSync$ python import_one.py Q1
Traceback (most recent call last):
  File "/home/jorge/TFM/WikibaseSync/import_one.py", line 8, in <module>
    wikibase_repo = wikibase.data_repository()
  File "/home/jorge/TFM/venv/lib/python3.10/site-packages/pywikibot/site/_apisite.py", line 1154, in data_repository
    return pywikibot.Site(url=url, user=self.username(),
  File "/home/jorge/TFM/venv/lib/python3.10/site-packages/pywikibot/__init__.py", line 1070, in Site
    code, fam = _code_fam_from_url(url, fam)
  File "/home/jorge/TFM/venv/lib/python3.10/site-packages/pywikibot/__init__.py", line 987, in _code_fam_from_url
    name = urlparse(url).netloc.split('.')[-2]
IndexError: list index out of range
CRITICAL: Exiting due to uncaught exception <class 'IndexError'>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants