CentOS python version is too low How to manually upgrade?

  

Python is a computer programming language. The succinct and extensible nature of the Python language has led to an increasing number of people using the language for scientific computing research, even setting up school courses. If the Python version is too low, it will not. Conducive to the use of the Python language, the following small series will introduce you to the way CentOS upgrades Python.

Host1Free's VPS is installed with CentOS 5.8 Final. Executing python -V (uppercase V) can see the version is Python 2.4.3. This is indeed an old version, but this is already a software library. The latest version. At this point you need to compile and install the latest Python 2.7.3.

One. Preparations

1. Install gcc:

GNU GCC compiler. Execution:

yum install gcc

2. Install the zlib library:

This library is not required, but if you do not install this library, it will cause Python's zlib built-in module to fail. Use, further can not use Python Egg to install the module, causing various troubles, so in order to avoid trouble, still install it. Execution:

yum install zlib zlib-devel

3.Download and extract the Python source package

Execute in order:

wget http://www. Python.org/ftp/python/2.7.3/Python-2.7.3.tgz #Download Python source package

tar zxvf Python-2.7.3.tgz #Unpack Python source package

two. Compile and install Python

Execute the following command in order:

cd Python-2.7.3

. /configure

make && make install

Compilation and installation of Python is time consuming. It is convenient to create a screen window before executing the above instructions.

After the above command is executed, we execute python -V again. We can see that the current version is already Python 2.7.3. If you want to call the old version of Python 2.4.3, execute python2.4. .

Three. Follow-up

After installation, because CentOS's yum depends on the system's own Python 2.4.3, if you use Python 2.7.3 to run it may be wrong, so we have to /usr/bin/yum file The first line in the #! /usr/bin/python is modified to #! /usr/bin/python2.4, so yum is executed when the old version of Python 2.4.3 is called. Modification can be done with vi, if you are not familiar with vi, you can use the SFTP function of Bitvise SSH Client to download the file, use Notepad++ (do not use the notebook that comes with Windows) to modify it and then upload it back (嘿嘿, I This is how it works once.)

Finally, install setuptools. When you download the Python module later, you can use the easy_install command. Execution:

wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg

sh setuptools-0.6c11-py2 .7.egg

as shown below:

the above is a Python version of CentOS upgrade method introduced, because Python is not automatically updated to 2.4.3, if you want to To use the latest Python version you will need to manually update it yourself.

Copyright © Windows knowledge All Rights Reserved