Wikiextractorのエラーについて(自分用メモ)

Pythonクローリング&スクレイピング[増補改訂版] -データ収集・解析のための実践開発ガイド・第5章にて

環境

エラーについて

wikipediaの記事データダンプファイルは、2021年4月20日更新版。ファイル名は
jawiki-20210420-pages-articles-multistream1.xml-p1p114794.bz2

wgetでWikiextractorのPythonスクリプトをダウンロードした後、書籍の通りに実行しようとしたが以下のようなエラーが出て実行できなかった。

(scraping)nuli@DESKTOP-PC1~$ python WikiExtractor.py --no_templates -o articles -b 100M jawiki-20210420-pages-articles-multistream1.xml-p1p114794.bz2
Traceback (most recent call last):
File "WikiExtractor.py", line 66, in <module>
from .extract import Extractor, ignoreTag, define_template, acceptedNamespaces
ImportError: attempted relative import with no known parent package

一応解決した方法

githubにあるWikiextractorのUsageに沿って実行した。
https://github.com/attardi/wikiextractorより引用

Usage
Wikiextractor
The script is invoked with a Wikipedia dump file as an argument:

python -m wikiextractor.WikiExtractor <Wikipedia dump file> [--templates <extracted template file>]

github.com

(scraping)nuli@DESKTOP-PC1:~$ git clone https://github.com/attardi/wikiextractor.git
(scraping)nuli@DESKTOP-PC1:~$ python -m wikiextractor.WikiExtractor jawiki-20210420-pages-articles1.xml-p1p114794.bz2 --no-templates -o articles -b 100M
INFO: Starting page extraction from jawiki-20210420-pages-articles1.xml-p1p114794.bz2.
INFO: Using 11 extract processes.
INFO: Finished 11-process extraction of 79423 articles in 39.2s (2025.9 art/s)

ちゃんとファイルが生成されているか確認

(scraping)nuli@DESKTOP-PC1:~$ tree articles/
articles/
└── AA
          ├── wiki_00
          ├── wiki_01
          ├── wiki_02
          └── wiki_03

1 directory, 4 files

vimでファイルの中身を見てみる

(scraping)nuli@DESKTOP-PC1:~$ vim articles/AA/wiki_00
<doc id="5" url="?curid=5" title="アンパサンド">
アンパサンド

アンパサンド (&amp;、英語名:) とは並立助詞「…と…」を意味する記号である。ラテン語の の合字で、Trebuchet MSフォントでは、と表示され "et" の合字であることが容易にわかる。
語源.
・・・

</doc>
<doc id="10" url="?curid=10" title="言語">
言語

・・・

urlが表示されていない・・・