centos7.9安装python 3.6.8 import pandas UserWarning: Could not import the lzma module

python环境安装

# 依赖安装
yum install libffi-devel -y
yum install zlib-devel -y
yum install bzip2-devel -y
yum install ncurses-devel -y
yum install sqlite-devel -y
yum install readline-devel -y
yum install tk-devel -y
yum install openssl-devel -y
# 编译安装python
tar -zxvf Python-3.6.8.tgz
cd Python-3.6.8
./configure --prefix=/usr/local/python3
make && make install


# 安装模块
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple requests




# 问题
/usr/local/python3/lib/python3.6/site-packages/pandas/compat/__init__.py:120: UserWarning: Could not import the lzma module.

# 解决:
yum install -y xz-devel
python3 -m pip install backports.lzma

# 修改文件/usr/local/python3/lib/python3.6/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,pandas,linux)