Python的安装及升级
安装官网:www.python.org
Window上需要自己安装,从官网下载即可。
Linux都已已发行版本都已经安装。
如果是windows环境,下载portable Python,绿色直接使用。
Python版本查看
1
2
# python -V
Python 2.6.6
CentOS6.6下Python2.6.6升级到2.7.3的步骤:
cd /home/myself/tools
wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar -jxvf Python-2.7.3.tar.bz2
cd Python-2.7.3
./configure
make all make install make clean make distclean但是使用python -V查看得时候还是2.6.6,因此需要将系统默认的python指向到2.7版本:mv /usr/bin/python /usr/bin/python2.6.6ln -s /usr/local/bin/python2.7 /usr/bin/python然后通过python -V查看就会显示为2.7.3了。
此时yum不能正常工作,解决此问题:vim /usr/bin/yum更改文件头部:#!/usr/bin/python改为:#!/usr/bin/python2.6.6一切OK!
第一个Python程序
1
2
3
4
5
6
# python
Python 2.7.3 (default, Mar 27 2016, 02:25:08)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello world!"
hello world!
页:
[1]