安装Python2.7
安装环境
[[email protected] ~]# cat /etc/redhat-release CentOS release 6.5 (Final) [[email protected] ~]# uname -a Linux localhost1 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
安装依赖包
[[email protected] ~]# yum -y install gcc openssl-devel bzip2-devel
下载python源码包
[[email protected] ~]# cd /usr/src/ [[email protected] src]# wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
解压
[[email protected] src]# tar xf Python-2.7.15.tgz [[email protected] src]# cd Python-2.7.15 [[email protected] Python-2.7.15]#
编译安装
[[email protected] Python-2.7.15]# ./configure --enable-optimizations [[email protected] Python-2.7.15]# make [[email protected] Python-2.7.15]# make altinstall
查看安装
[[email protected] Python-2.7.15]# /usr/local/bin/python2.7 -V Python 2.7.15
设置软连接
[[email protected] Python-2.7.15]# mv /usr/bin/python{,-old} [[email protected] Python-2.7.15]# ln -s /usr/local/bin/python2.7 /usr/bin/python
配置yum
[[email protected] Python-2.7.15]# sed -i ‘s/python/python-old/‘ /usr/bin/yum
安装pip
[[email protected] Python-2.7.15]# python -m ensurepip Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-9.0.3 setuptools-39.0.1 [[email protected] Python-2.7.15]# pip -V pip 9.0.3 from /usr/local/lib/python2.7/site-packages (python 2.7)
原文地址:https://www.cnblogs.com/LuckWJL/p/9183405.html
时间: 2024-11-07 16:08:35