Python 3 and Python 2 Multi-version coexistence (Linux), python3python2

Source: Internet
Author: User

Python 3 and Python 2 Multi-version coexistence (Linux), python3python2
Python3 has come out for some time. Compared with python2, python3 has made a lot of improvements, including syntax, new functions, and optimization. Although many libraries support python2 and python3 at the same time, some libraries still do not support python3 well, so sometimes we still need to use python2. I started learning python last year. As a beginner without historical burdens, I naturally chose python3 for learning. But after installing the new python3, the newly installed Python 3 inevitably conflicts with the built-in Python 2. Including calls of different versions and python library Installation Tools (pip and easy_install) of different versions ). This article describes the environments in which python2 and pyhon3 coexist, including python 3 installation, pip installation, and how to call these two python versions. Ubuntu configuration method 1. Install python2. Most linux distributions come with python2. Do not install it separately.

$ sudo apt-get install python2
2. Install easy_install for python2

Use wget for installation (root permission may be required)[Recommended]

$ wget https://bootstrap.pypa.io/ez_setup.py -O - | python2
Or download ez_install.py and then install it.
$ python2 ez_install.py

As you can see, the installation script ez_setup.py supports two python versions. If you use python2 to run the script, the installed easy_install is for python2. Similarly, if you use python3 to run the script, the installed easy_install is for python3.

3. Install pip for python2
$ easy_install-2.7 pip
Pip2.7 install xxx4 and install python3
$ sudo apt-get install python3
5. Install easy_install for python3 Use wget for installation (root permission may be required) [recommended]
$ wget https://bootstrap.pypa.io/ez_setup.py -O - | python2
OrDownload ez_install.py and then install
$ python ez_install.py
5. Install pip for python3
$ easy_install pip
Use

Python2

Python

Easy_install

Pip

Python3 

Python3

Easy-install3

Pip3

 

Install python3 in archlinux
$ sudo pacman -S python
Install python2
$ sudo pacman -S python2 
For archlinux easy_install pip that is included in the software library python-setuptoolspython-pippython2-setuptoolspython2-pip use Python2Python2 easy_install-2.7pip2.7 Python3Pythoneasy-installpip

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.