最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

CentOS7.3編譯安裝Python3.6.2的方法

 更新時間:2018年01月22日 16:40:57   作者:My_Oh_My  
本篇文章主要介紹了CentOS7.3編譯安裝Python3.6.2的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

我使用的是 CentOS7.3 安裝 Python3.6.2

1.查看是否已經(jīng)安裝Python

Centos7 默認安裝了Python2.7.5 因為一些命令要用它比如 yum 它使用的是 python2.7.5.

使用 python -V 命令查看一下是否安裝 Python:

# python -V
Python 2.7.5

然后查看一下 Python 可執(zhí)行文件的位置:

# which python
/usr/bin/python

進入到 bin 目錄:

# cd /usr/bin/
# ls -al python*
lrwxrwxrwx. 1 root root  34 8月 25 08:18 python -> python2
lrwxrwxrwx. 1 root root  9 8月 19 21:32 python2 -> python2.7
-rwxr-xr-x. 1 root root 7136 11月 6 2016 python2.7

可以看到可執(zhí)行文件 python 指向 python2 ,python2 又指向 python2.7 也就是說 Python 命令執(zhí)行的系統(tǒng)預(yù)裝的 Python2.7.

要安裝 Python 的其他版本先執(zhí)行 mv python python.bak 命令備份 python 文件。

# mv python python.bak
# ls -al python*
lrwxrwxrwx. 1 root root  9 8月 19 21:32 python2 -> python2.7
-rwxr-xr-x. 1 root root 7136 11月 6 2016 python2.7
lrwxrwxrwx. 1 root root  7 8月 19 21:32 python.bak -> python2

2.修改 yum 配置文件

因為yum使用CentOS7.3默認安裝的Python 2.7.5,因此替換為Python 3.6.2后無法正常工作.

# yum repolist
 File "/usr/bin/yum", line 30
  except KeyboardInterrupt, e:
              ^
SyntaxError: invalid syntax

因此修改yum配置文件,繼續(xù)使用Python2.7.5.

更改yum腳本的python依賴

# cd /usr/bin
# ls -al yum*
-rwxr-xr-x. 1 root root  801 11月 15 2016 yum
-rwxr-xr-x. 1 root root 9429 11月 6 2016 yum-builddep
-rwxr-xr-x. 1 root root 8582 11月 6 2016 yum-config-manager
-rwxr-xr-x. 1 root root 7609 11月 6 2016 yum-debug-dump
-rwxr-xr-x. 1 root root 7903 11月 6 2016 yum-debug-restore
-rwxr-xr-x. 1 root root 10999 11月 6 2016 yumdownloader
-rwxr-xr-x. 1 root root 11031 11月 6 2016 yum-groups-manager

使用vim更改以上文件頭,把 #!/usr/bin/python 改為 #!/usr/bin/python2

修改gnome-tweak-tool配置文件

# vim /usr/bin/gnome-tweak-tool

把文件頭 #!/usr/bin/python 改為 #!/usr/bin/python2

修改urlgrabber配置文件

# vim /usr/libexec/urlgrabber-ext-down

把文件頭 #!/usr/bin/python 改為 #!/usr/bin/python2

3.編譯環(huán)境準備

安裝開發(fā)套件用于編譯 Python3.6.2 源碼

# yum groupinstall 'Development Tools'

安裝 python3.6.2 可能會使用到的依賴

復(fù)制代碼 代碼如下:

# yum install -y ncurses-libs zlib-devel mysql-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

4.安裝 Python3.6.2

到官網(wǎng)獲取最新版的 Python3.6.2 下載地址 https://www.python.org/downloads/source/

下載 tgz.xz 包就可以了. Python-3.6.2.tar.xz ,這個是 Python 的源碼.

執(zhí)行wget 命令直接下載到當前文件夾:

# wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

解包:

# xz -d Python-3.6.2.tar.xz

解壓縮:

# tar -xvf Python-3.6.2.tar.xz

解壓縮之后出現(xiàn) Python-3.6.2 文件夾.

# ll
drwxr-xr-x. 17 max max   4096 8月 25 01:22 Python-3.6.2
-rw-rw-r--. 1 max max 83169280 7月 17 11:55 Python-3.6.2.tar

進入到Python-3.6.2文件夾下,編譯源碼

# cd Python-3.6.2/
# ./configure --prefix=/usr/local/python3.6 --enable-optimizations

先解釋上面的參數(shù):

--prefix選項是配置安裝的路徑,如果不配置該選項,安裝后可執(zhí)行文件默認放在/usr/local/bin,庫文件默認放在/usr/local/lib,配置文件默認放在/usr/local/etc,其它的資源文件放在/usr/local/share,比較凌亂.

如果配置--prefix,如:./configure --prefix=/usr/local/python3.6可以把所有資源文件放在/usr/local/python3.6的路徑中,不會雜亂.用了--prefix選項的另一個好處是卸載軟件或移植軟件。當某個安裝的軟件不再需要時,只須簡單的刪除該安裝目錄,就可以把軟件卸載得干干凈凈;移植軟件只需拷貝整個目錄到另外一個相同的操作系統(tǒng)機器即可.當然要卸載程序,也可以在原來的make目錄下用一次make uninstall,但前提是make文件指定過uninstall.

--enable-optimizations 是優(yōu)化選項(LTO,PGO 等)加上這個 flag 編譯后,性能有 10% 左右的優(yōu)化,但是這會明顯的增加編譯時間,老久了.

./configure命令執(zhí)行完畢之后創(chuàng)建一個文件 Makefile, 供下面的make命令使用,執(zhí)行make install之后就會把程序安裝到我們指定的文件夾中去.

然后執(zhí)行make命令

# make

再執(zhí)行make install命令

# make install

安裝完成之后進入到/usr/local/python3.6目錄,可以看到Python的可執(zhí)行文件目錄bin等相關(guān)目錄.

# cd /usr/local/python3.6
# ll
總用量 4
drwxr-xr-x. 2 root root 4096 8月 25 08:07 bin
drwxr-xr-x. 3 root root  24 8月 25 08:07 include
drwxr-xr-x. 4 root root  63 8月 25 08:07 lib
drwxr-xr-x. 3 root root  17 8月 25 08:07 share

進入bin目錄,可以看到很多相關(guān)的可執(zhí)行文件,目前只需要關(guān)注python3.6、pip3.6.

# cd bin
# ll
總用量 22552
lrwxrwxrwx. 1 root root    8 8月 25 08:07 2to3 -> 2to3-3.6
-rwxr-xr-x. 1 root root   111 8月 25 08:07 2to3-3.6
-rwxr-xr-x. 1 root root   252 8月 25 08:07 easy_install-3.6
lrwxrwxrwx. 1 root root    7 8月 25 08:07 idle3 -> idle3.6
-rwxr-xr-x. 1 root root   109 8月 25 08:07 idle3.6
-rwxr-xr-x. 1 root root   224 8月 25 08:07 pip3
-rwxr-xr-x. 1 root root   224 8月 25 08:07 pip3.6
lrwxrwxrwx. 1 root root    8 8月 25 08:07 pydoc3 -> pydoc3.6
-rwxr-xr-x. 1 root root    94 8月 25 08:07 pydoc3.6
lrwxrwxrwx. 1 root root    9 8月 25 08:07 python3 -> python3.6
-rwxr-xr-x. 2 root root 11526224 8月 25 08:06 python3.6
lrwxrwxrwx. 1 root root    17 8月 25 08:07 python3.6-config -> python3.6m-config
-rwxr-xr-x. 2 root root 11526224 8月 25 08:06 python3.6m
-rwxr-xr-x. 1 root root   3107 8月 25 08:07 python3.6m-config
lrwxrwxrwx. 1 root root    16 8月 25 08:07 python3-config -> python3.6-config
lrwxrwxrwx. 1 root root    10 8月 25 08:07 pyvenv -> pyvenv-3.6
-rwxr-xr-x. 1 root root   451 8月 25 08:07 pyvenv-3.6

5.修改軟鏈接配置 Python3.6 、pip3.6 為系統(tǒng)默認

# ln -s /usr/local/python3.6/bin/python3.6 /usr/bin/python
# ln -s /usr/local/python3.6/bin/pip3.6 /usr/bin/pip

進入/usr/bin目錄查看相關(guān)軟鏈接配置結(jié)果:

# cd /usr/bin
# ls -al python*
lrwxrwxrwx. 1 root root  34 8月 25 08:18 python -> /usr/local/python3.6/bin/python3.6
lrwxrwxrwx. 1 root root  9 8月 19 21:32 python2 -> python2.7
-rwxr-xr-x. 1 root root 7136 11月 6 2016 python2.7
lrwxrwxrwx. 1 root root  7 8月 19 21:32 python.bak -> python2

# ls -al pip*
lrwxrwxrwx. 1 root root 31 8月 25 08:21 pip -> /usr/local/python3.6/bin/pip3.6

查看系統(tǒng)默認 Python、pip版本:

# python -V
Python 3.6.2

# python2 -V
Python 2.7.5

# pip -V
pip 9.0.1 from /usr/local/python3.6/lib/python3.6/site-packages (python 3.6)

現(xiàn)在系統(tǒng)默認的python版本為Python 3.6.2,而CentOS7.3默認安裝的Python 2.7.5現(xiàn)在可以使用python2調(diào)用.pip 也變成了最新版本的.

到這里CentOS7.3 編譯安裝 Python3.6.2就完成了!

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • pytorch sampler對數(shù)據(jù)進行采樣的實現(xiàn)

    pytorch sampler對數(shù)據(jù)進行采樣的實現(xiàn)

    今天小編就為大家分享一篇pytorch sampler對數(shù)據(jù)進行采樣的實現(xiàn),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • python使用pyecharts繪制簡單的折線圖

    python使用pyecharts繪制簡單的折線圖

    這篇文章講給大家介紹一下python使用pyecharts繪制簡單的折線圖的黨法步驟,文中有詳細的代碼示例講解,對我們學習或工作有一定的幫助,需要的朋友可以參考下
    2023-07-07
  • python 模塊導(dǎo)入問題匯總

    python 模塊導(dǎo)入問題匯總

    在本篇文章里小編給大家整理的是一篇關(guān)于python 模塊導(dǎo)入問題匯總內(nèi)容,有需要的朋友們可以學習參考下。
    2021-02-02
  • Python爬蟲基礎(chǔ)講解之請求

    Python爬蟲基礎(chǔ)講解之請求

    今天帶大家了解一下python爬蟲的基礎(chǔ)知識,文中有非常詳細的解釋說明,對正在學習python爬蟲的小伙伴們有很好地幫助,需要的朋友可以參考下
    2021-05-05
  • Python操作dict時避免出現(xiàn)KeyError的幾種解決方法

    Python操作dict時避免出現(xiàn)KeyError的幾種解決方法

    這篇文章主要介紹了Python操作dict時避免出現(xiàn)KeyError的幾種解決方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-09-09
  • Python入門篇之編程習慣與特點

    Python入門篇之編程習慣與特點

    本文是Python入門篇的第一篇文章,主要講述了Python編程習慣和特點等一些基礎(chǔ)知識,有需要的朋友可以參考下
    2014-10-10
  • Python中的常用函數(shù)使用及說明

    Python中的常用函數(shù)使用及說明

    這篇文章主要介紹了Python中的常用函數(shù)使用及說明,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • Django分頁功能的實現(xiàn)代碼詳解

    Django分頁功能的實現(xiàn)代碼詳解

    在本篇文章里小編給大家整理了關(guān)于Django分頁功能的實現(xiàn)代碼以及相關(guān)知識點內(nèi)容,需要的朋友們可以跟著學習參考下。
    2019-07-07
  • python中import與from方法總結(jié)(推薦)

    python中import與from方法總結(jié)(推薦)

    這篇文章主要介紹了python中import與from方法總結(jié),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-03-03
  • keras topN顯示,自編寫代碼案例

    keras topN顯示,自編寫代碼案例

    這篇文章主要介紹了keras topN顯示,自編寫代碼案例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-07-07

最新評論

延川县| 通许县| 台北县| 阳江市| 桂平市| 囊谦县| 涿州市| 罗源县| 宜宾市| 平阳县| 江都市| 沛县| 恩施市| 涞源县| 游戏| 扎赉特旗| 天全县| 察雅县| 拉萨市| 海城市| 玉田县| 天水市| 永吉县| 丰原市| 萨嘎县| 吉首市| 大方县| 偃师市| 靖宇县| 阿坝| 嫩江县| 西青区| 余庆县| 夹江县| 富源县| 贵定县| 全南县| 甘孜| 田阳县| 固阳县| 柳江县|