Python-based version of Python installed in Ubuntu system

Source: Internet
Author: User

As Python updates, the new version is different from the old version of the feature point, as a beginner should understand the old version of the rules, but also continue to learn the new version of knowledge. In order to be able to learn Python better, I installed python2 and Python in Ubuntu

3 for later study.



The installation steps are as follows:

1. See if Python is installed under the system

Dpkg-s python

Ubuntu 12.04 comes with the Python2.7.3 version

2, the use of Apt-get mode installation 2.7.3 version

Apt-get Install Python

3. Install other versions, such as python3.5

(1) Installing dependent packages and libraries

Note: Because of the need to install in a compiled manner, a large number of libraries and dependent packages are needed, so we need to make them ready before compiling.

sudo apt-get install build-essential libncursesw5-dev libreadline6-dev libssl-dev libgdbm-dev Libc6-dev Libs
Qlite3-dev Tk-dev bzip2 libbz2-dev-y

(2) Download source code

wget HTTP://WWW.PYTHON.ORG/FTP/PYTHON/3.5.2/PYTHON-3.5.2.TAR.XZ
(3) Decompression and installation

Tar xvf python-3.5.2.tar.xz -c/usr/local/src #解压

cd/usr/local/src/python-3.5.2 #进入解压目录

./configure--prefix=/opt/python3 #/opt/python3.5.2 is a Python installation directory, or you can select a different directory

Make && make install #安装

(4) After installation, a soft connection is established so that the python3 can be called directly.

Ln-s/opt/python3/bin/python3.5/usr/local/bin/python3

4. Testing

Python2

Python3

Python based on the installation of two versions of Python under Ubuntu system

Related Article

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.