1. 下載
官網(wǎng)下載需要執(zhí)行的安裝文件塞栅。
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0a1.tar.xz
2.解壓安裝包
利用tar命令解壓文件到當(dāng)前目錄。
tar xvf Python-3.7.0a1.tar.xz
3.安裝
安裝Python3.7安裝到/usr/local目錄中,執(zhí)行configure放椰。
./configure --prefix=/usr/local
注意執(zhí)行出現(xiàn):
configure: error: no acceptable C compiler found in $PATH
因?yàn)槭莄entos linux,默認(rèn)可以采用yum方式安裝庄敛,則采用如下命令安裝gcc編譯器即可:
yum -y install gcc
前提是linux可以在線更新。
執(zhí)行安裝命令
make&& make install
4.測(cè)試
在線測(cè)試python3是否安裝成功
python3
顯示如下
Python 3.7.0a1 (default, Oct 27 2017, 12:28:35)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
5.Hello world
創(chuàng)建一個(gè)hello.py文件
#!/usr/bin/python3
print("hello world!");
執(zhí)行hello.py文件
python hello.py
#打印如下
hello world!
微信號(hào):even366