Installing Python 3.6.1 on CentOS 7

Source: Internet
Author: User

CentOS 7 installs Python 2.7 by default, and the system itself uses it to enable system commands such as ' yum '

Although as a developer I can do a lot of things with Python 2.7, I really want to take advantage of the new language features that are included with Python 3. Since Python 3.6 came out at the end of last year, we've got more good things like _literal string interpolation _ or _f strings, but the default Yum source can only be installed to python3.4, if you want to use python3.6, refer to the following:

Install the necessary applications

As with all Linux tutorials, you first install the update. Then I can continue to install the necessary tools and utilities.

sudo yum updatesudo yum install yum-utilssudo yum groupinstall development

All the required packages are now installed.

Install Python 3.6.1

The standard Yum repository has not yet provided the latest Python version, so I need to install an additional repository called IUM(Inline with Upstream Stable), which provides the necessary RPM packages.

So, to install the Ium repository:

sudo yum install https://centos7.iuscommunity.org/ius-release.rpm

Now that the repository is installed, I can continue to install Python 3.6:

sudo yum install python36u

Now it's time to check the Python version (which should be Python 3.6.1 returned when writing this article):

python3.6 -V

Next, _pip_ to manage Python packages and some development packages.

sudo yum install python36u-pipsudo yum install python36u-devel
Other PIP for python3.6 installation methods
wget https://bootstrap.pypa.io/get-pip.py sudo python3.6 get-pip.py

Install Pip_package with PIP

sudo python3.6 -m pip install PIP_PACKAGE
To prepare the test:
# This should return the system Python versionpython –V# output:Python 2.7.5# This should return the Python 3 versionpython3.6 –V# output:Python 3.6.1

Now I'm ready to run Python 3.6 for my application!

Create a Virtualenv

The preferred way to create a new virtualenv in Python 3 is to run (in the project directory):

python3.6 -m venv venv

... The former venv is the command that creates the virtualenv, which is the name of the venv virtualenv.

To activate Virtualenv and start using the PIP installation package, run:

. venv/bin/activatepip install [package_name]pip install -r requirements.txt

Installing Python 3.6.1 on CentOS 7

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.