`lzma` module is not available
Python 2023/9/28 11:18:41 点击:不统计
使用python开发过程中出现 `lzma` module is not available,Could not import the lzma module.
查看扩展插件使用的是
import lzma
出现 Could not import the lzma module.
进入python 后
$ python
Python 3.8.13 (default, Sep 25 2023, 17:34:28)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lzma # 运行命令
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gonika/.pyenv/versions/3.8.13/lib/python3.8/lzma.py", line 27, in <module>
from _lzma import *
ModuleNotFoundError: No module named '_lzma'
提示没有对应的module ,并给出了python 环境中的 lzma.py 文件地址以及行数。
修正该问题:
(1)首先安装一下
pip install backports.lzma
如果是mac
brew install openssl readline sqlite3 xz zlib
xcode-select --install
(2)修改上述出错的文件 27行
原来
from _lzma import *
from _lzma import _encode_filter_properties, _decode_filter_properties
修改为:
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
这样就解决了,上述问题。
·上一篇:Ubuntu安装rpm >> ·下一篇:python flask >>