Python3中import pandas后提示错误

问题

import pandas后提示:
Warning: 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
2
sudo apt install liblzma-dev
pip install backports-lzma

修改/usr/local/lib/python3.10/lzma.py第27行,改成如下内容:

1
2
3
4
5
6
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