发布时间:2019-09-26 07:36:40编辑:auto阅读(1785)
安装gcc readline* 等,不然会出问题
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel -y
1. 从Python官网到获取Python3的包, 切换到目录/usr/local/src
#wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz
2. 使用命令如下命令进行解压缩:
1 xz -d Python-3.5.1.tar.xz2 tar -xf Python-3.5.1.tar
3. 在/usr/local路径下创建目录--python3.5, 为第4步的安装目录
$mkdir /usr/local/python3.5
4. 编译安装(会自动安装pip-7.1.2)
$cd /usr/local/src/Python-3.5.1 #./configure --prefix=/usr/local/python3.5 #make all #make install #make clean #make distclean
5. 进入安装的绝对路径,检查是否安装成功
$ /usr/local/python3.5/bin/python3.5 -V Python 3.5.1
6.查看环境变量,启动python时默认按照PATH的顺序进行查找,在/usr/bin中的python此时为Python2.6的。
$echo $PATH /usr/lib/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/gordon/bin
7.修改软连接,启动python时指向python3.5
备份python mv /usr/bin/python /usr/bin/python2.6.6 sudo ln -s /usr/local/python3.5/bin/python3 /usr/bin/python
8. 验证默认是否启动python3.5
$ python -V Python 3.5.1
9. 升级完python之后,yum就不好用了,需要修改/usr/bin/yum,改为使用python2.6.6
#!/usr/bin/python2.6.6
上一篇: 对python3编码那些事的小小总结
下一篇: Python3快速入门(十五)——Pan
47750
46254
37136
34643
29233
25893
24762
19866
19428
17916
5720°
6324°
5843°
5892°
6993°
5831°
5851°
6365°
6319°
7684°