zhiliang 2020-02-10
1)首先安装gcc编译器,gcc有些系统版本已经默认安装,通过 gcc --version 查看,没安装的先安装gcc,yum -y install gcc
2)安装其它依赖包,(注:不要缺少,否则有可能安装python出错,python3.7.0以下的版本可不装 libffi-devel )
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
1)在https://www.python.org/ftp/python/中选择自己需要的python源码包,我下载的是python3.7.0
2)下载
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar -zxvf Python-3.7.0.tgz
mkdir /usr/local/python3
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install
安装完成没有提示错误便安装成功了
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
[ Python-3.7.0]# python3
Python 3.7.0 (default, Jul 28 2018, 22:47:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello world!")
hello world!
>>> exit()
[ Python-3.7.0]# pip3 --version
pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)
可以看到python3.7.0可以正常使用