需要用到的安装包:
Python-3.10.0.tgz
numpy-1.26.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pyparsing-3.1.1-py3-none-any.whl
pytz-2023.3.post1-py2.py3-none-any.whl
six-1.16.0-py2.py3-none-any.whl
python_dateutil-2.8.2-py2.py3-none-any.whl
cycler-0.12.1-py3-none-any.whl
kiwisolver-1.4.5-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
contourpy-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Pillow-10.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
fonttools-4.46.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
packaging-23.2-py3-none-any.whl
matplotlib-3.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
tzdata-2023.3-py2.py3-none-any.whl
pandas-2.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
以上安装包已放到网盘,客官可一键下载:
链接:https://pan.baidu.com/s/1MFNuy04v5L1B5g88qE73BQ?pwd=19g2
提取码:19g2
1、安装python3
安装python 相关的依赖包(需要自己配置yum源)
(不要问为啥不批量安装,已经踩过坑,若中间有一个包安装错误 后面的包有概率不会安装,直接无脑复制粘贴安装即可)
yum install -y gcc
yum install -y patch
yum install -y libffi-devel
yum install -y python-devel
yum install -y zlib
yum install -y zlib-devel
yum install -y bzip2
yum install -y bzip2-devel
yum install -y openssl-devel
yum install -y ncurses-devel
yum install -y sqlite-devel
yum install -y readline-devel
yum install -y tk-devel
yum install -y gdbm-devel
yum install -y libpcap-devel
yum install -y ncurses
yum install -y openssl
yum install -y openssl-static
yum install -y xz
yum install -y lzma
yum install -y xz-devel
yum install -y sqlite
yum install -y gdbm
yum install -y tk
解压python源码包
tar -zxf Python-3.10.0.tgz
cd Python-3.10.0
./configure --prefix=/usr/local/python3/
编译安装
make && make install
配置环境变量
vi /etc/profile
#python
PATH=/usr/local/python3/bin:$PATH
source /etc/profile
安装成功
python3 -V
pip3 -V
2、离线安装pandas
上传安装包服务器上
注意安装包有tar.gz文件和whl文件
tar.gz文件兼容性好,whl文件安装方便.
(gz安装方法为:
tar -zxvf 文件名
cd 文件夹
python3 setup.py install)
本文以whl文件安装为例。
需要下面命令,切记一定要一行一行的按顺序执行,如果某一个安装失败,或者提示报错,请看下面的解决方法。
安装
pip3 install numpy-1.26.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pip3 install pyparsing-3.1.1-py3-none-any.whl
pip3 install pytz-2023.3.post1-py2.py3-none-any.whl
pip3 install six-1.16.0-py2.py3-none-any.whl
pip3 install python_dateutil-2.8.2-py2.py3-none-any.whl
pip3 install cycler-0.12.1-py3-none-any.whl
pip3 install kiwisolver-1.4.5-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
pip3 install contourpy-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pip3 install Pillow-10.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
pip3 install fonttools-4.46.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pip3 install packaging-23.2-py3-none-any.whl
pip3 install matplotlib-3.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pip3 install tzdata-2023.3-py2.py3-none-any.whl
pip3 install pandas-2.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
这是安装成功的截图
这是安装失败的截图
像这种,matplotlib安装它有版本限制,需要对提示的安装包进行升级,本文已经提供的有对应安装包和安装命令,安装上面的命令进行升级即可。
升级
contourpy
pip3 install contourpy-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Pillow
pip3 install Pillow-10.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
fonttools
pip3 install fonttools-4.46.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
packaging
pip3 install packaging-23.2-py3-none-any.whl
再次安装matplotlib,看到可以成功安装了
安装pandas,也需要升级tzdata
pip3 install tzdata-2023.3-py2.py3-none-any.whl
安装成功后,输入python3 命令进入命令行,查看能否导入pandas
测试
python3
import numpy as np
import pandas as pd
s=pd.Series([1,2,3,np.nan,5,6])
print(s)
3、结束
以上安装已完成。