Saki's 研究记录

Python3安装pandas报错Could not import the lzma module

字数统计: 158阅读时长: 1 min
2021/11/30

环境

Centos: Linux release 8.4.2105 (Core)
Python: 3.9.5
GCC: 8.4.1 20200928 (Red Hat 8.4.1-1)

问题

Centos安装pandas包后运行报错:

1
Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError.

原因及解决办法

因为我环境上的Python 3.9.5是源码安装的,所以必须预先安装lzma-dev包,否则编译出来的Python是不会包含lzma的。

1
2
3
4
# Ubuntu: 
apt-get install liblzma-dev
# Centos:
yum install -y xz-devel

然后重新源码编译安装Python,具体步骤见之前<<No module named ‘_ssl’>>

Reference

. UserWarning: Could not import the lzma module. Your installed Python is incomplete

Done.

CATALOG
  1. 1. 环境
  2. 2. 问题
  3. 3. 原因及解决办法
  4. 4. Reference