解决办法:Python3.x UserWarning: Could not import the lzma module. Your installed Python is incomplete

问题描述: 系统为:CentOS Linux release 8.2.2004 (Core) 执行Python脚本的时候出现:

UserWarning: Could not import the lzma module. Your installed Python is incomplete
python3安装pandas库出现: Could not import the lzma module

刚开始的时候浪费了很长时间,有的网上大哥出招说:进入/usr/local/python3/lib/python3.7目录下,
编辑lzma.py 巴拉巴拉什么的,根本都不管用,依然报错,而且这样的文章抄来抄去不在少数,都不解决问题。


原因分析: 出现该错误的原因,是因为在依次执行完./configuresudo make 的时候出现了错误提示,被忽略了。
如果发现在执行make的时候出现类似下面的错误提示,那么就是因为依赖包没有提前安装好,需要提前安装好。
提示如下:

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_dbm                  _gdbm                 _lzma              nis
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

解决办法: 依次执行如下命令:

  1. sudo yum install -y xz-devel
  2. cd Python-3.8.5
  3. sudo ./configure --prefix=/usr/local/python3.8.5 --enable-optimizations --with-ssl
  4. sudo make
  5. sudo make install

再次运行python脚本,问题得到解决。



如果是乌班图系统,比如 `Ubuntu 18.04`:
sudo apt-get install lzma

依次执行如下命令:

sudo apt-get install liblzma-dev
sudo apt-get install lzma
sudo ./configure --prefix=/usr/local/python3.8.5 --enable-optimizations --with-ssl
sudo make
sudo make altinstall


补充几个模块依赖包的对应关系:
  • _lzma 的依赖包是:xz-devel
  • _dbm_gdbm 的依赖包是:gdbm-devel
  • _sqlite3 的依赖包是:sqlite-devel
  • readline 的依赖包是:readline-devel
  • nis 的依赖包是:nispor-devel

:本文原创由 bluetata 发布于https://bluetata.blog.csdn.net/、转载请务必注明出处。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bluetata

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值