linux下安装python_Linux下python3.7 的安装

Linux中已经自带了Python2.7.5,之前也安装了python3.6,但是当前代码运行需要python3.7,所以需要安装python3.7,也不能影响之前安装的其他版本的python。

  1. linux自带Python2.7.5,如下:

[root@T-zichan-odb1-16-26 ~]# python --version

Python 2.7.5

[root@T-zichan-odb1-16-26 ~]# python

Python 2.7.5 (default, Nov 6 2016, 00:28:07)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> exit()

2.当前代码运行需要python3.7,所以需要安装python3.7

  1. [root@T-zichan-odb1-16-26 ~]# whereis python

  2. python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python3.6 /usr/bin/python3.6m /usr/lib/python2.7 /usr/lib/python3.6 /usr/lib64/python2.7 /usr/lib64/python3.6 /etc/python /usr/include/python2.7 /usr/include/python3.6m /usr/share/man/man1/python.1.gz

  3. [root@T-zichan-odb1-16-26 ~]# ls -l /usr/bin/python*

  4. lrwxrwxrwx. 1 root root 7 4月 10 2019 /usr/bin/python -> python2

  5. lrwxrwxrwx. 1 root root 9 4月 10 2019 /usr/bin/python2 -> python2.7

  6. -rwxr-xr-x. 1 root root 7136 11月 6 2016 /usr/bin/python2.7

  7. lrwxrwxrwx 1 root root 9 4月 11 2019 /usr/bin/python3 -> python3.6

  8. lrwxrwxrwx 1 root root 18 4月 11 2019 /usr/bin/python36 -> /usr/bin/python3.6

  9. -rwxr-xr-x 2 root root 11408 3月 29 2019 /usr/bin/python3.6

  10. -rwxr-xr-x 2 root root 11408 3月 29 2019 /usr/bin/python3.6m

/usr/bin/python,/usr/bin/python2和python3都是软链接,/usr/bin/python指向/usr/bin/python2,而/usr/bin/python2最终又指向/usr/bin/python2.7

/usr/bin/python3和/usr/bin/python36都指向python3.6

3.安装python3.7

3.1下载python3.7

下载地址:

https://www.python.org/downloads/source/

8e1240307d8679cafd26c0b1d4894bb1.png

下载完成后解压压缩包

tar -zxvf Python-3.7.8.tgz

3.2安装依赖包

  1. yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

  2. yum install libffi-devel

3.3 编译安装并创建软链接

  1. cd Python-3.7.8

  2. ./configure --prefix=/usr/bin/python3.7

  3. make

  4. make install

  5. ln -s /usr/bin/python3.7/bin/python3.7 /usr/bin/python37

3.4验证

[root@T-zichan-odb1-16-26 Python-3.7.8]# python37

Python 3.7.8 (default, Jul 27 2020, 17:24:09)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> exit()

没有影响到其他版本的python

[root@T-zichan-odb1-16-26 ~]# python3

Python 3.6.6 (default, Mar 29 2019, 00:03:27)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> exit()

[root@T-zichan-odb1-16-26 ~]# python

Python 2.7.5 (default, Nov 6 2016, 00:28:07)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> exit()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值