linux已经安装python2时如何再安装python3

深度链接 / 2023-12-06 21:48:36 / 154

如何在已经安装python2的环境中安装python3?

1、系统环境

[root@wrx install]# python
Python 2.6.6 (r266:84292, Aug 18 2016, 14:53:48) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
[root@wrx install]# pwd
/var/data/install
[root@wrx install]# uname
Linux
[root@wrx install]# uname -a
Linux wrx 2.6.32-642.13.1.el6.i686 #1 SMP Wed Jan 11 20:21:04 UTC 2017 i686 i686 i386 GNU/Linux
[root@wrx install]# cat /etc/redhat-release 
CentOS release 6.8 (Final)

2、python3.4安装

[root@wrx install]# wget  
[root@wrx install]# tar -zxf Python-3.4.4.tgz
[root@wrx install]# cd Python-3.4.4.tgz

#配置
[root@wrx Python-3.4.4]# ./configure 
#编译
[root@wrx Python-3.4.4]# make -j 2
#安装
[root@wrx Python-3.4.4]# make install

注:
make -j [N], --jobs[=N]          同时允许 N 个任务;无参数表明允许无限个任务。

3、命令测试

[root@wrx Python-3.4.4]# python3
Python 3.4.4 (default, Jun 18 2017, 18:37:40) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.