Centos共存python3

1、Python版本下载

所有版本下载地址

我下载的是3.6.5版本

服务器腾讯云Centos7.4

2、解压

[root@VMcentos ~]# pwd
/root
[root@VMcentos ~]# wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
[root@VMcentos ~]# ls
Python-3.6.5.tgz
[root@VMcentos ~]# tar -zxvf Python-3.6.5.tgz

3、安装

[root@VMcentos Python-3.6.5]# pwd
/root/Python-3.6.5
[root@VMcentos Python-3.6.5]# ls
aclocal.m4    configure.ac  install-sh  Makefile.pre.in  Parser    pyconfig.h.in  Tools
config.guess  Doc           Lib         Misc             PC        Python
config.sub    Grammar       LICENSE     Modules          PCbuild   README.rst
configure     Include       Mac         Objects          Programs  setup.py
[root@VMcentos Python-3.6.5]# ./configure 
[root@VMcentos Python-3.6.5]# sudo make
[root@VMcentos Python-3.6.5]# sudo make install

命令解释:

  • 设置安装路径: ./configure –prefix=/usr/python3(默认/usr/local/bin)
  • 编辑:make
  • 安装:make install
  • 创建软连接:ln -s 源路径 目标路径

4、安装成功

[root@VMcentos ~]# pwd
/root
[root@VMcentos ~]# python3 -V
Python 3.6.5
[root@VMcentos ~]# python -V
Python 2.7.5
[root@VMcentos bin]# pip -V
pip 9.0.3 from /usr/lib/python2.7/site-packages (python 2.7)
[root@VMcentos bin]# pip3 -V
pip 9.0.3 from /usr/local/lib/python3.6/site-packages (python 3.6)

猜你喜欢

转载自blog.csdn.net/qq_1290259791/article/details/81228345