您好,登錄后才能下訂單哦!
今天小編給大家分享一下CentOS 7.6下怎么編譯安裝Python 3.8.0的相關(guān)知識點(diǎn),內(nèi)容詳細(xì),邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。
[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
不安裝也有可能不會(huì)報(bào)錯(cuò),但是安裝了一定不會(huì)報(bào)錯(cuò),安不安裝自己把握。
[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
安裝完成后,若出現(xiàn)以下兩行,說明安裝成功;
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 系統(tǒng)本身是帶的有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的,[做運(yùn)維的小年輕]那我們現(xiàn)在安裝了python3.7,是不是可以將python命令做一個(gè)軟鏈接鏈接到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”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會(huì)為大家更新不同的知識,如果還想學(xué)習(xí)更多的知識,請關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。