ubuntu下_import pandas出现Could not import the lzma module
运行环境:pyenv python =3.6.8pandas = 1.1.5OS = Ubuntu 18.04问题描述:pandas库可以安装成功,但是在import的时候出现了错误提示UserWarning:Could not import the lzma module......Python 3.6.8 (default, Nov9 2021, 00:29:48)[GCC 7.4.0] on
·
运行环境:
pyenv python =3.6.8
pandas = 1.1.5
OS = Ubuntu 18.04
问题描述:
pandas库可以安装成功,但是在import的时候出现了错误提示
UserWarning: Could not import the lzma module......
Python 3.6.8 (default, Nov 9 2021, 00:29:48)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
/home/kql/.pyenv/versions/kql/lib/python3.6/site-packages/pandas/compat/__init__.py:120: 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)
>>>
解决:
安装libbz2-dev, lzma,liblzma-dev 然后pip install backports.lzma
sudo apt-get install libbz2-dev
sudo apt-get install lzma
sudo apt-get install liblzma-dev
pip install backports.lzma
接着找到lzma.py文件,修改文件27,28两行
from _lzma import *
from _lzma import _encode_filter_properties, _decode_filter_properties
#找到lzma.py文件的位置
find / -name lzma.py
/home/kql/.pyenv/versions/3.6.8/lib/python3.6/lzma.py
#把原来的两行代码修改如下
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 安装pandas库出现Could not import the lzma module
https://www.cnblogs.com/gaodp/p/15270116.html
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)