Python 3 has been installed in Linux and has been upgraded.

Source: Internet
Author: User

Python 3 has been installed in Linux and has been upgraded.
Install Python 3 in Linux to complete the upgrade

python

First download the sourcetarPackage

You can use the built-in linux download tool wget to download, as shown below:

 
 
  1. # 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:

 
 
  1. tar -zxvf Python-3.1.2.tar

Enter the decompressed folder

 
 
  1. cd Python-3.1.2

Before compilation/usr/localCreate a folderpython3(pythonTo avoid overwriting the old version), you need to usesudoPermission

 
 
  1. mkdir /usr/local/python3

Start compilation and Installation

 
 
  1. ./configure --prefix=/usr/local/python3
  2. make
  3. make install

--prefix=/usr/local/python3GeneratemakefileFile, where the installation directory (linuxThe installation under is to copy the file to the system path after compiling the link) specified,makeThe link will be compiled.makefileTarget file,make installRunmakefileTo complete the installation.

The old version is not overwritten./usr/bin/pythonThe link is changed to another name.

 
 
  1. mv /usr/bin/python /usr/bin/python_old

Create a new versionpython.

 
 
  1. ln -s /usr/local/python3/bin/python3 /usr/bin/python

Enter

 
 
  1. Python # displays the new version of python.
  2. Python 3.1.2 (r312:79147, Oct 21 2012, 01:03:21))
  3. [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>>

If you do not create a new installation pathpython3Is directly installed by default.pythonIt should overwritelinuxIf you want to keep the original version, so this method is best.

You can alsopython2Andpython3Coexistence, that is, do not change the name of the old version.python3.

 
 
  1. ln -s /usr/local/python3/bin/python3 /usr/bin/python3

In this way, enterpythonWill enter the old version; enterpython3Will enter the new version, the two coexist, you need to use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.