
1.本次使用的是一台全新的腾讯云主机,首先获取linux系统版本信息。
[root@VM_46_121_centos ~]# cat /etc/redhat-release
<本系统默认自带python2.7.5>
[root@VM_46_121_centos ~]# python
Python 2.7.5 (default, Sep 15 2016, 22:37:39)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
CentOS Linux release 7.2.1511 (Core)
2.因为后期要用到pip3,所以先安装openssl,openssl-devel。
[root@VM_46_121_centos ~]# yum -y install openssl openssl-devel
3.下载编译安装python3.5,记的先下载gcc-c++!
[root@VM_46_121_centos ~]# cd /usr/local/src/
[root@VM_46_121_centos src]# wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
[root@VM_46_121_centos src]# tar -zxvf Python-3.5.2.tgz
[root@VM_46_121_centos src]# cd Python-3.5.2/
[root@VM_46_121_centos Python-3.5.2]# ./configure && make all && make install
[root@VM_46_121_centos Python-3.5.2]# python3
Python 3.5.2 (default, Apr 21 2017, 16:32:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
4.如果你想升级python版本到python3.5的话,如下操作。
[root@VM_46_121_centos Python-3.5.2]# mv /usr/bin/python /usr/bin/python2.6
[root@VM_46_121_centos Python-3.5.2]# ln -s /usr/local/bin/python3.5 /usr/bin/python
别忘了vim /usr/bin/yum
解决升级python导致yum不可用的问题!
5.因为我喜欢玩ipython所以使用pip3安装了。
[root@VM_46_121_centos Python-3.5.2]# pip3 install ipython
6.现在python3.5环境是没有任何问题的!需要执行什么py脚本直接python3.5+脚本即可!
[root@VM_46_121_centos python]# python3.5 simple.py
Please input an domain:www.baidu.com
www.a.shifen.com.
61.135.169.125
61.135.169.121
7.我的需求就这么简单!