centos下更新Python版本的步骤
安装完CentOS5.9(Final)后,执行#Python与#python -V,看到版本号是2.4.3,很老了,而且之前写的都是跑在python3.X上面的,3.X和2.X有很多不同,有兴趣的朋友可以参考下这篇文章:
http://www.bitsCN.com/article/34011.htm
更新python千万不要把老版本的删除!新老版本是可以共存的,很多基本的命令、软件包都要依赖预装的老版本python的,比如yum。
更新python:
第1步:更新gcc,因为gcc版本太老会导致新版本python包编译不成功
代码如下:
#yum -y install gcc
系统会自动下载并安装或更新,等它自己结束
第2步:下载Python-3.3.0软件包
代码如下:
#wget http://python.org/ftp/python/3.3.0/Python-3.3.0.tar.bz2
注意:按照上述命令下载的软件包会存放在你当前的工作目录下,wget命令是一个从网络上自动下载文件的自由工具,具体用法,请参考这篇文章:http://www.bitsCN.com/os/RedHat/73089.html
说明:命令中的数字就是版本号,你也可以把3.3.0换成你需要的版本,截止至我撰稿时(2013年1月29日),最新可用版本是3.3.0
第3步:解压已下载的二进制包并编译安装
代码如下:
#tar -jxvf Python-3.3.0.tar.bz2
#cd Python-3.3.0
#./configure
#make all
#make install
#make clean
#make distclean
# /usr/local/bin/python3 –V
编译安装完毕以后,可以输入上面一行命令,查看版本
第4步:建立软连接指向到当前系统默认python命令的bin目录,让系统使用新版本python
#mv /usr/bin/python /usr/bin/python2.4 //当前python的版本为2.4所以是python2.4
#ln -s /usr/local/bin/python3.3 /usr/bin/python
输入#python -V,即可查看当前默认python版本
默认的python成功指向3.3.0以后,yum不能正常使用,需要修改yum的配置文件
第5步:修改yum配置文件
#vi /usr/bin/yum
把文件头部的#!/usr/bin/python改成#!/usr/bin/python2.4 //改为之前的老版本号
保存退出,yum即可正常使用。如若有其他命令、软件不能正常使用,仿照yum配置文件的修改方法,修改其配置文件即可。
至此,更新完毕。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

To run Python code in Sublime Text, you need to install the Python plug-in first, then create a .py file and write the code, and finally press Ctrl B to run the code, and the output will be displayed in the console.

Golang is better than Python in terms of performance and scalability. 1) Golang's compilation-type characteristics and efficient concurrency model make it perform well in high concurrency scenarios. 2) Python, as an interpreted language, executes slowly, but can optimize performance through tools such as Cython.

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

Running Python code in Notepad requires the Python executable and NppExec plug-in to be installed. After installing Python and adding PATH to it, configure the command "python" and the parameter "{CURRENT_DIRECTORY}{FILE_NAME}" in the NppExec plug-in to run Python code in Notepad through the shortcut key "F6".
