标签:python安装
在学习一门语言之前,咱们先了解为什么我们要学它。
python是一个脚本语言,语言简单,兼容各版本系统,学习这门语言将对以后的运维日常工作提供极大的便利。
1.1 Linux 下 python 安装
首先从官网下载所需要的 python 版本,解压后直接编译安装即可,
[root@server /]# tar -zxf Python-2.7.11.tgz
[root@server /]# cd Python-2.7.11
[root@server /]# ./configure && make && make install
然后我们可以在安装目录查看到 Python 2.7.11 版本已经安装
[root@server usr]# /usr/local/bin/python
Python 2.7.11 (default, Jan 2 2017, 12:16:39)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
但是我们系统自带版本为 python 2.6.6,我们如何替换成编译好的 python 2.7.11 呢
[root@server usr]# python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
我们先进入系统 python 所在目录,把启动文件备份下,然后删除
[root@server usr]# cd ..
[root@server /]# cp /usr/bin/python /usr/bin/python.bak.2017
[root@server /]# rm /usr/bin/python
rm: remove regular file `/usr/bin/python‘? y
接着我们把编译好的 python 2.7.11 版本的启动文件做个软连接到当前目录下,之后我们再查看python 版本时,就变成我们编译的版本了
[root@server /]# ln -s /usr/local/bin/python2.7 /usr/bin/python
[root@server /]# python
Python 2.7.11 (default, Jan 2 2017, 12:16:39)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
1.2 Windows 下 python 安装
从官网下载安装包添加环境变量即可。
标签:python安装
原文地址:http://shaoniana.blog.51cto.com/11471609/1974832