Python安装

1安装需要的包

yum groupinstall "Development tools"
yum install zlib-devel  bzip2-devel openssl-devel  ncurses-devel  sqlite-devel
2下载安装 Python 2.7.10

--下载
cd /opt
wget --no-check-certificate https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
tar xf Python-2.7.10.tar.xz
cd Python-2.7.10
--编译安装
./configure
make  
make altinstall
3将Python命令指向 Python 2.7.10

[root@fyl bin]# whereis python
python: /usr/bin/python /usr/bin/python2.6 /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python2.7 /usr/local/bin/python2.7-config /usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
[root@fyl bin]# rm /usr/bin/python
[root@fyl bin]# ln -s /usr/local/bin/python2.7 /usr/bin/python
[root@fyl bin]# python
Python 2.7.10 (default, Sep 12 2015, 13:12:13) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> exit()
4简单语法
[root@fyl Python]# more hello.py 
#!/usr/bin/python
print "hello woord!"
[root@fyl Python]# python hello.py 
hello woord!


你可能感兴趣的:(Python安装)