Python 3 has been installed in Linux and has been upgraded.
Install Python 3 in Linux to complete the upgrade
python
First download the sourcetar
Package
You can use the built-in linux download tool wget to download, as shown below:
# wget http://www.python.org/ftp/python/3.3.0/Python-3.3.0.tgz
You can also download other versions from the official website or use a browser if you have an interactive interface. There are many ways to download the source code. The following code is used for installation.
After the download is complete, go to the download directory and decompress and unpack the package:
tar -zxvf Python-3.1.2.tar
Enter the decompressed folder
cd Python-3.1.2
Before compilation/usr/local
Create a folderpython3
(python
To avoid overwriting the old version), you need to usesudo
Permission
mkdir /usr/local/python3
Start compilation and Installation
./configure --prefix=/usr/local/python3
make
make install
--prefix=/usr/local/python3
Generatemakefile
File, where the installation directory (linux
The installation under is to copy the file to the system path after compiling the link) specified,make
The link will be compiled.makefile
Target file,make install
Runmakefile
To complete the installation.
The old version is not overwritten./usr/bin/python
The link is changed to another name.
mv /usr/bin/python /usr/bin/python_old
Create a new versionpython
.
ln -s /usr/local/python3/bin/python3 /usr/bin/python
Enter
Python # displays the new version of python.
Python 3.1.2 (r312:79147, Oct 21 2012, 01:03:21))
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
If you do not create a new installation pathpython3
Is directly installed by default.python
It should overwritelinux
If you want to keep the original version, so this method is best.
You can alsopython2
Andpython3
Coexistence, that is, do not change the name of the old version.python3
.
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
In this way, enterpython
Will enter the old version; enterpython3
Will enter the new version, the two coexist, you need to use