python3.6.1 的 cent7.3 下安装
安装编译工具:
[root@localhost ~]# yum -y install gcc gcc-c++
安装依赖包:
[root@localhost ~]# yum -y install zlib* openssl*
[root@localhost ~]# ls
Python-3.6.1.tgz
[root@localhost ~]# tar -zxf Python-3.6.1.tgz
[root@localhost ~]# ls
Python-3.6.1 Python-3.6.1.tgz
[root@localhost ~]# cd Python-3.6.1
[root@localhost Python-3.6.1]# ls
aclocal.m4 config.sub configure.ac Grammar install-sh LICENSE Makefile.pre.in Modules Parser PCbuild pyconfig.h.in README.rst Tools
config.guess configure Doc Include Lib Mac Misc Objects PC Programs Python setup.py
[root@localhost Python-3.6.1]# ./configure --prefix=/usr/local/python3.6.1 --enable-optimizations
#最后表示优化,带优化
[root@localhost Python-3.6.1]# make && make install
安装完后,将源码的 python 目录删掉,防止搞混了:
[root@localhost Python-3.6.1]# cd
[root@localhost ~]# ls
Python-3.6.1 Python-3.6.1.tgz
[root@localhost ~]# ls /usr/local/python3.6.1/
bin include lib share
[root@localhost ~]# rm -rf Python-3.6.1
[root@localhost ~]# ls /usr/local/python3.6.1/bin/
2to3 easy_install-3.6 idle3.6 pip3.6 pydoc3.6 python3.6 python3.6m python3-config pyvenv-3.6
2to3-3.6 idle3 pip3 pydoc3 python3 python3.6-config python3.6m-config pyvenv
[root@localhost ~]# vim /etc/profile #整个系统的环境变量配置文件,也可用~/.bashrc,表示当前用户的环境变量配置
文件。
#最后添加:
PATH=$PATH:/usr/local/python3.6.1/bin/
[root@localhost ~]# source /etc/profile
[root@localhost ~]# python3
Python 3.6.1 (default, Jul 9 2019, 21:13:25)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()