0

I'm working on Ubuntu 22.04 LTS and I'm trying to debug my python code within a virtual environment created with the help of pyenv and poetry 1.1.13 as a package manager.

I get this message in the debugging console trying to import

ModuleNotFoundError: No module named '_lzma'

when i try to import _lzma using:

from _lzma import *

From what I can gather its related to package installation errors, I have tried installing it manually but the problem persists.

lemon
  • 14,875
  • 6
  • 18
  • 38
nepipi6200
  • 1
  • 1
  • 1

2 Answers2

1

Based on pyenv wiki, you should install the desired python version with --enable-framework flag.

PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.6.7

The reason is that the module you're trying to use is implemented in C, and CPython with shared libraries will be built with the aforementioned flag.

Najem
  • 11
  • 4
0

Solution

frist

yum install xz-devel
yum install python-backports-lzma
pip install backports.lzma

second go to file where exeception originated

cd /usr/local/lib/python3.8
vi lzma.py 

finally modify about line 27 to


try:
    from _lzma import *
    from _lzma import _encode_filter_properties, _decode_filter_properties
except ImportError:
    from backports.lzma import *
    from backports.lzma import _encode_filter_properties, _decode_filter_properties

it‘s work!I had to search for hours to get this problem to be solved.

Credit: Yolo5 issues