您的位置:首页 > 运维架构 > Linux

python linux 安装

2015-09-30 17:06 459 查看
参考文件地址
http://ericslau.iteye.com/blog/1845654
下载安装包
 可利用linux自带下载工具wget下载,如下所示:
1 # wget http://www.python.org/ftp/python/3.3.0/Python-3.3.0.tgz 2 tar -xzvf Python-3.3.0.tgz)
进入压缩目录后在执行以下命令
1 cd Python-3.3.0
在编译前先在/usr/local建一个文件夹python3(作为python的安装路径,以免覆盖老的版本)
1 mkdir /usr/local/python3 ,一定要进入解压后得目录,里面才会有configure 该文件

开始编译安装
1 ./configure --prefix=/usr/local/python3 执行该命令后创建makefile文件

2 make
3 make install
注意

在执行./configure --prefix=/usr/local/python3 ,时出现 checking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking for --enable-universalsdk... nochecking for --with-universal-archs... 32-bitchecking MACHDEP... linuxchecking for --without-gcc... nochecking for gcc... nochecking for cc... nochecking for cl.exe... noconfigure: error: in `/usr/local/Python/Python-3.3.0':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details执行yum -y install gcc 后在安装执行上述命令即可
此时没有覆盖老版本,再将原来/usr/bin/python链接改为别的名字
1 mv /usr/bin/python /usr/bin/python_old

  再建立新版本python的链接
1 ln -s /usr/local/python3/bin/python3 /usr/bin/python

  这个时候输入
1 python

  就会显示出python的新版本信息
1 Python 3.1.2 (r312:79147, Oct 21 2012, 01:03:21))
2 [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
3 Type "help", "copyright", "credits" or "license" for more information.
4 >>>

  PS:如果不建立新安装路径python3,而是直接默认安装,则安装后的新python应该会覆盖linux下自带的老版本,也有可能不覆盖,具体看安装过程了,这个大家可以自己试验下,当然如果还想保留原来的版本,那么这种方法最好不过了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  centos python升级