centos 6 升级 python 到 2.7
python install 2.7 on centos 6
Linux系统默认的python版本号是2.6,为了让windows/osx/centos多平台都保持同一版本号,我们决定升级python到2.7!
一、 先查看你的系统是什么版本号。如我的系统是 Centos6.5 64Bit。
[root@python ~]# uname -a
Linux python 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
显示为python2.6 设备为centos6.5 64x,在这之前你可能需要检查一下 gcc~~之类的有没有安装!
# yum groupinstall "Development tools"
# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
# pip install mysql-python
二、 安装python环境
Python下载地址:
# mkdir /usr/local/python27
# wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
# wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz
# tar -zxvf Python-2.7.10.tgz
# cd Python-2.7.10
# ./configure prefix=/usr/local/python27/
# make && make install
安装完成,但是启动时需要指定正确的路径,非常不方便!这里我们给定它系统路径。
# ln -s /usr/local/python27/bin/python2.7 /usr/local/bin/python27
三、检查一下是版本是否正确。有否升级到2.7
# python27 -V
Python 2.7.10
四、测试
# python27
Python 2.7.10 (default, Mar 13 2016, 16:35:05)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
#>>> help()
__Welcome to Python 2.7! This is the online help utility.
If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type “quit”.
To get a list of available modules, keywords, or topics, type “modules”,
“keywords”, or “topics”. Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as “spam”, type “modules spam”.
# ln -s /usr/local/python27/bin/python2.7 /usr/local/bin/python
编辑/usr/bin/yum,将第一行的#!/usr/bin/python修改成#!/usr/bin/python2.6.6
# wget https://bootstrap.pypa.io/get-pip.py
# python get-pip.py
# whereis pip
# ln -s /usr/local/bin/pip2.7 /usr/bin/pip
# pip install psutil requests paramiko
# yum groupinstall "Development Tools"
40 yum install gcc -y
41 yum install gcc-c++ -y
47 cd /usr/local/src/
49 wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
51 tar -zxvf Python-2.7.8.tgz
52 cd Python-2.7.8
54 mkdir -p /usr/local/python27
55 ./configure --prefix=/usr/local/python27/
56 make
57 make install
58 cd /usr/local/python27/
63 python -V
65 ./python2.7 -V
71 cd include/
74 cd python2.7/
77 cp -a ./* /usr/local/include/
78 cd /usr/bin/
79 ll python
81 mv python python26
82 ln -s /usr/local/python27/bin/python2.7 python
84 ll python*
85 python -V
88 ll python8
90 vim /usr/bin/yum
91 yum makecache
- 点赞
- 收藏
- 关注作者
评论(0)