🐍

ModuleNotFoundError: No module named '_lzma'

2 min read

エラー

  • OS:CentOS-8.2
  • 言語:Python-3.7.5

エラー詳細:

Traceback (most recent call last):
  File "/home/gz/.venvs/beam/lib/python3.7/site-packages/fastavro/read.py", line 2, in <module>
    from . import _read
  File "fastavro/_read.pyx", line 11, in init fastavro._read
  File "/home/gz/.pyenv/versions/3.7.5/lib/python3.7/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gz/.pyenv/versions/3.7.5/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/home/gz/.pyenv/versions/3.7.5/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/home/gz/tmp/beam/sdks/python/apache_beam/__init__.py", line 95, in <module>
    from apache_beam import coders
  File "/home/gz/tmp/beam/sdks/python/apache_beam/coders/__init__.py", line 19, in <module>
    from apache_beam.coders.coders import *
  File "/home/gz/tmp/beam/sdks/python/apache_beam/coders/coders.py", line 47, in <module>
    from apache_beam.coders import coder_impl
  File "/home/gz/tmp/beam/sdks/python/apache_beam/coders/coder_impl.py", line 55, in <module>
    from fastavro import parse_schema
  File "/home/gz/.venvs/beam/lib/python3.7/site-packages/fastavro/__init__.py", line 47, in <module>
    import fastavro.read
  File "/home/gz/.venvs/beam/lib/python3.7/site-packages/fastavro/read.py", line 4, in <module>
    from . import _read_py as _read  # type: ignore
  File "/home/gz/.venvs/beam/lib/python3.7/site-packages/fastavro/_read_py.py", line 12, in <module>
    import lzma
  File "/home/gz/.pyenv/versions/3.7.5/lib/python3.7/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

解決方法:

lzmaのモジュールはxz-utilsをインストールすることで解決できます。

http://www.s-yata.jp/docs/xz-utils/
sudo yum install xz xz-devel

それからpythonを削除して、再インストールしてください。

確認方法:

pythonでlzmaをimportして。エラーがなかったこと。

>python
import lzma

Discussion

ログインするとコメントできます