centos7.4 mini安裝沒有圖形,關閉selinux和firewall。系統默認是python2.7
[root@controller ~]# python Python 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
python的模塊安裝方法是easy_install或pip,系統上默認沒有。
1、安裝企業擴展yum
yum install epel-release -y
yum search easy_install
有如下的結果:
python2-pip.noarch : A tool for installing and managing Python 2 packages
python34-pip.noarch : A tool for installing and managing Python3 packages
yum install python34-pip
就可以使用pip3安裝python3的相關軟件包了。
[root@controller ~]# python python python2 python2.7 python3 python3.4 python3.4m [root@controller ~]# pip3 pip3 pip3.4
如果不是搞OpenStack等,還是使用python3吧。
python2同python3的一個差異是
3要加括弧print ()