您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
今天小编给大家分享一下CentOS 7.6下怎么编译安装Python 3.8.0的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。
[root@python3 ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)
[root@python3 ~]# cd /etc/yum.repos.d/ [root@python3 yum.repos.d]# mkdir bak [root@python3 yum.repos.d]# mv * bak [root@python3 yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo [root@python3 yum.repos.d]# wget http://mirrors.aliyun.com/repo/epel-7.repo
[root@python3 ~]# yum -y install zlib-devel bzip2-devel openssl-devel openssl-static ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel lzma gcc
不安装也有可能不会报错,但是安装了一定不会报错,安不安装自己把握。
[root@python3 ~]# cd /usr/local/src/ [root@python3 src]# wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
将安装包下载到/usr/local/src/目录下
[root@python3 src]# tar xvf Python-3.7.0.tar.xz [root@python3 src]# mv Python-3.7.0 /usr/local/python-3.7 [root@python3 src]# cd /usr/local/python-3.7/
[root@python3 python-3.7]# ./configure --prefix=/usr/local/sbin/python-3.7
将python3.7安装到/usr/local/sbin/python-3.7目录下
[root@python3 python-3.7]# make && make install
安装完成后,若出现以下两行,说明安装成功;
Installing collected packages: setuptools, pip Successfully installed pip-10.0.1 setuptools-39.0.1
[root@python3 python-3.7]# /usr/local/sbin/python-3.7/bin/python3
Python 3.7.0 (default, Mar 15 2019, 00:44:37)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
【此处退出的命令 exit()】
虽然能用了,但是命令较长使用起来并不方便,we konw 系统本身是带的有python的,看一下版本
[root@python3 ~]# python -V
Python 2.7.5
[root@python3 ~]# which python
/usr/bin/python
[root@python3 ~]# ll /usr/bin/ |grep python
-rwxr-xr-x. 1 root root 11312 Nov 14 00:00 abrt-action-analyze-python
lrwxrwxrwx. 1 root root 7 Mar 14 18:19 python -> python2
lrwxrwxrwx. 1 root root 9 Mar 14 18:19 python2 -> python2.7
-rwxr-xr-x. 1 root root 7216 Oct 31 07:46 python2.7
可以看到python命令是通过软链接连接到python2.7的,[做运维的小年轻]那我们现在安装了python3.7,是不是可以将python命令做一个软链接链接到python3,答案是肯定的昂。
[root@python3 ~]# rm -rf /usr/bin/python [root@python3 ~]# ln -sv /usr/local/sbin/python-3.7/bin/python3 /usr/bin/python ‘/usr/bin/python’ -> ‘/usr/local/sbin/python-3.7/bin/python3’ [root@python3 ~]# ll /usr/bin/ |grep python -rwxr-xr-x. 1 root root 11312 Nov 14 00:00 abrt-action-analyze-python lrwxrwxrwx. 1 root root 38 Mar 14 19:24 python -> /usr/local/sbin/python-3.7/bin/python3 lrwxrwxrwx. 1 root root 9 Mar 14 18:19 python2 -> python2.7 -rwxr-xr-x. 1 root root 7216 Oct 31 07:46 python2.7
[root@python3 ~]# python -V Python 3.7.0
①将/usr/bin/yum的顶部的: !/usr/bin/python 改成 !/usr/bin/python2.7 ②将/usr/libexec/urlgrabber-ext-down的顶部的: /usr/bin/python 改为 /usr/bin/python2.7 ③将/usr/bin/yum-config-manager的顶部的 #!/usr/bin/python 改为 #!/usr/bin/python2.7
[root@python3 ~]# ln -s /usr/local/sbin/python-3.7/bin/pip3 /usr/bin/pip [root@python3 ~]# pip --version pip 10.0.1 from /usr/local/sbin/python-3.7/lib/python3.7/site-packages/pip (python 3.7)
以上就是“CentOS 7.6下怎么编译安装Python 3.8.0”这篇文章的所有内容,感谢各位的阅读!相信大家阅读完这篇文章都有很大的收获,小编每天都会为大家更新不同的知识,如果还想学习更多的知识,请关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。