python pip3 安装pandas报错

[root@edb1 ~]$ pip3 install pandas

Traceback (most recent call last):
  File "", line 1, in
  File "/usr/local/python3/lib/python3.10/site-packages/pandas/__init__.py", line 48, in
    from pandas.core.api import (
  File "/usr/local/python3/lib/python3.10/site-packages/pandas/core/api.py", line 48, in
    from pandas.core.groupby import (
  File "/usr/local/python3/lib/python3.10/site-packages/pandas/core/groupby/__init__.py", line 1, in
    from pandas.core.groupby.generic import (
  File "/usr/local/python3/lib/python3.10/site-packages/pandas/core/groupby/generic.py", line 70, in
    from pandas.core.frame import DataFrame
  File "/usr/local/python3/lib/python3.10/site-packages/pandas/core/frame.py", line 157, in
    from pandas.core.generic import NDFrame
  File "/usr/local/python3/lib/python3.10/site-packages/pandas/core/generic.py", line 129, in
    from pandas.core.describe import describe_ndframe
  File "/usr/local/python3/lib/python3.10/site-packages/pandas/core/describe.py", line 38, in
    from pandas.io.formats.format import format_percentiles
  File "/usr/local/python3/lib/python3.10/site-packages/pandas/io/formats/format.py", line 99, in
    from pandas.io.common import (
  File "/usr/local/python3/lib/python3.10/site-packages/pandas/io/common.py", line 4, in
    import bz2
  File "/usr/local/python3/lib/python3.10/bz2.py", line 17, in
    from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'

 1、找到系统自带的python文件夹,找到_bz2.cpython-36m-x86_64-linux-gnu.so,复制到/user/local/python3/lib/python3.10中,

[root@pghost4 ~]# sudo cp /usr/lib/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so  /usr/local/python3/lib/python3.10/
[root@pghost4 ~]# cd /usr/local/python3/lib/python3.10/
[root@pghost4 ~]# mv _bz2.cpython-36m-x86_64-linux-gnu.so _bz2.cpython-310-x86_64-linux-gnu.so

 2、有些情况是并没有在自带的里面找到_bz2.cpython-36m-x86_64-linux-gnu.so类似这样的文件,那怎么办呢?答案就是:从网上下载一个,放到/usr/local/python3/lib/python3.10中,注意_bz2.cpython-xxx,这几个xxx版本号要与对应要放的文件夹家的版本号一致。

网址:https://pan.baidu.com/s/14lGw-SDzTa0eqNYVJEs2tQ 
提取码:mxwg

你可能感兴趣的:(python,linux,pycharm)