Linux下安装python 2.7.13
目录
1.安装依赖的库
yum -y install python-devel openssl openssl-devel gcc sqlite sqlite-devel mysql-devel libxml2-devel libxslt-devel
1.下载
[root@cdh-server1 ~]# pwd
/root
[root@cdh-server1 ~]# wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
[root@cdh-server1 ~]# ll
总用量 36852
-rw-r--r-- 1 root root 17076672 12月 18 04:21 Python-2.7.13.tgz
2、解压、编译安装(依次执行以下5条命令)
[root@cdh-server1 ~]# tar -zxf Python-2.7.13.tgz
[root@cdh-server1 ~]# cd Python-2.7.13
[root@cdh-server1 ~]# ./configure --prefix=/usr/local/python2.7 --with-threads --enable-shared
[root@cdh-server1 ~]# make && make altinstall
备份旧python相关命令
===> 有些版本/usr/bin/目录下不存在pip 或者easy_install 忽略下面第1,2行命令即可
[root@cdh-server1 ~]# mv /usr/bin/pip /usr/bin/pip_old
[root@cdh-server1 ~]# mv /usr/bin/easy_install /usr/bin/easy_install_old
[root@cdh-server1 ~]# mv /usr/bin/python /usr/bin/python_old
新版本python命令做软连接,快捷使用
[root@server2 Python-2.7.13]# ln -s /usr/local/python2.7/lib/libpython2.7.so /usr/lib
[root@server2 Python-2.7.13]# ln -s /usr/local/python2.7/lib/libpython2.7.so.1.0 /usr/lib
[root@server2 Python-2.7.13]# ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python
[root@server2 Python-2.7.13]# ln -s /usr/local/python2.7/lib/libpython2.7.so /usr/lib64
[root@server2 Python-2.7.13]# ln -s /usr/local/python2.7/lib/libpython2.7.so.1.0 /usr/lib64
测试python是否可以正常使用
[root@server2 ~]# python
Python 2.7.13 (default, Apr 11 2017, 11:14:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
参考:https://blog.csdn.net/u012071918/article/details/78817344
转载自:https://blog.csdn.net/qq_21383435/article/details/83278750