python-3.xwikipedialzmapywikibot

Pywikibot: _lzma module missing


I've developped a Python script which use Pywikibot. The scripts works fine on Windows 11 but i need to run it on Linux Server with CentOS 7.

But, there was an issue involving a missing module named _lzma.

File "/opt/scripts/10_-_One_Shot_Scripts/dlweb_wikipedia_extract_page_list.py", line 21, in <module>
    import pywikibot
  File "/usr/local/lib/python3.9/site-packages/pywikibot/__init__.py", line 21, in <module>
    from pywikibot import config as _config
  File "/usr/local/lib/python3.9/site-packages/pywikibot/config.py", line 68, in <module>
    from pywikibot.logging import error, output, warning
  File "/usr/local/lib/python3.9/site-packages/pywikibot/logging.py", line 36, in <module>
    from pywikibot.tools import deprecated_args, issue_deprecation_warning
  File "/usr/local/lib/python3.9/site-packages/pywikibot/tools/__init__.py", line 12, in <module>
    import lzma
  File "/usr/local/lib/python3.9/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

I tried to install Pylzma but it didn't fix the issue. Following this thread, i've installed dependencies:

yum install yum-utils
sudo yum-builddep python3

but it didn't fix the issue either.

I didn't use a virtual env by the way...


Solution

  • So, after lots of searching around and following this,it seems that this module should have been installed during Python installation. So, i've re-installed Python (and upgrade from 3.9.17 to 3.9.19) and everything work fine.