How to configure the default Python version of Ubuntu

Source: Internet
Author: User

ubuntu 16.04本身是自带python的,他本身是自带2.X和3.X,两个版本,默认的是2.X。这里记录一下如果在版本间切换以及如何把python版本切换到3.X下的方法。

1. See the version of Python installed in Ubuntu and the Python version currently in use

Ls/usr/bin/python*python--version

2. Set Update-alternatives to toggle Python version

Show python in place of version information

Update-alternatives--list python

Show after execution

Update-alternatives:error:no alternatives for Python means Python replaces version not yet installed

Perform a command installation

Update-alternatives--install/usr/bin/python python/usr/bin/python2.7 1

update-alternatives:using/usr/bin/python2.7 to Provide/usr/bin/python (python) in auto mode

Update-alternatives--install/usr/bin/python python/usr/bin/python3.5 2

update-alternatives:using/usr/bin/python3.5 to Provide/usr/bin/python (python) in auto mode

View the default version

Python--version

Because we set the/usr/bin/python3.5 setting to a priority of 2 in the above command, the update-alternatives command itself sets 3.5 as the default

Show Python instead of version information again

Update-alternatives--list python

Toggle version Update-alternatives--config python sudo update-alternatives --config python 3.python3 version installation pipsudo apt-get install PYTHON3-PIP running pip3-v display version upgrade PIP version PIP3 install--upgrade pip

How to configure the default Python version of Ubuntu

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.