在默认安装Centos 6.4中,系统默认安装的Python版本为2.6.6,最新版本为3.3.5,因此打算升级一下。
特别注意,如果默认编码是GB18030,请修改为LANG="en_US.UTF-8",不然编译不成功!
一键操作:
0 |
yum install zlib zlib-devel gcc gcc-c++ openssl openssl-devel libffi-devel -y |
0 |
0 1 2 3 4 5 6 7 8 9 10 11 |
#libffi-devel 解决 wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz tar zxf Python-3.6.5.tgz cd Python-3.6.5 ./configure --prefix=/opt/Python-3.6.5 --enable-optimizations make make install cd /opt/Python-3.6.5/bin for i in `ls -l | awk '{print $9}' | grep -v "^$"`; do ln -s /opt/Python-3.6.5/bin/$i /usr/local/bin/$i; done cd /opt python3.6 -m venv py3 source /opt/py3/bin/activate |
0 |
0 |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@WWW Byrd]# wget http://www.python.org/ftp/python/3.3.5/Python-3.3.5.tgz [root@WWW Byrd]# tar zxvf Python-3.3.5.tgz [root@WWW Byrd]# cd Python-3.3.5 [root@WWW Python-3.3.5]# mkdir /usr/local/python3 [root@WWW Python-3.3.5]# ./configure --prefix=/usr/local/python3 [root@WWW Python-3.3.5]# make [root@WWW Python-3.3.5]# make install [root@WWW Python-3.3.5]# mv /usr/bin/python /usr/bin/python_old [root@WWW Python-3.3.5]#ln -s /usr/local/python3/bin/python3 /usr/bin/python [root@WWW Python-3.3.5]# python Python 3.3.5 (default, Mar 13 2014, 09:08:41) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> |
如果yum报错参考:http://note.t4x.org/system/file-yum-except-keyboardinterrupt/SourceByrd's Weblog-https://note.t4x.org/system/centos-update-python/
申明:本文由BYRD原创(基于Centos6.4 X64),未经许可禁止转载!SourceByrd's Weblog-https://note.t4x.org/system/centos-update-python/ SourceByrd's Weblog-https://note.t4x.org/system/centos-update-python/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Trackbacks