python运行异常UserWarning:Could not import the lzma module .Your installed Python is incomplet

python运行异常UserWarning:Could not import the lzma module .Your installed Python is incomplete(import pandas)

  • 错误提示:
>>> import pandas
/usr/local/python3.9/lib/python3.9/site-packages/pandas/compat/__init__.py:124: UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError.
  warnings.warn(msg)
  • 解决方法:
  1. 安装backports.lzma
pip install backports.lzma
  1. 找到安装的的lzma.py(在安装的python目录中的/lib/python3.*目录中,如:/usr/local/python3.9/lib/python3.9)。

  2. 修改lzma.py文件:

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

你可能感兴趣的:(python,linux)