Wednesday, March 28, 2018

How to install Python 3.6.1 on CentOS 7

Same because the last time, CentOS seven still has Python two.7 put in out of the box and is employed by the system itself to alter the system commands, thus let’s not mess therewith installation.

Although as a developer I will do plenty with Python two.7, i actually need to utilize the new language options that comes with Python three. Since Python three.6 initiate within the finish of last year, we have a tendency to got even additional goodies, like Literal String Interpolation, or the f-strings, as they're known as.

Let’s start. By the way, this doesn't break the installation I created within the previous article, thus no worries, if you're on constant server installation because the last time.

Install the necessary utilities

As all UNIX operating system tutorials out there, very first thing is to put in the updates. The I will proceed with the installation of the required tools and utilities.

[root@local ~]# sudo yum update
[root@local ~]# sudo yum install yum-utils
[root@local ~]# sudo yum groupinstall development

Now all of the required packages are put in.

Install Python 3.6.1

The standard yum repositories doesn't however give the most recent Python unharness, thus i want to put in a further repository, known as IUM (Inline with Upstream Stable), that provides the required revolutions RPM packages.

So, to install IUM repository:

[root@local ~]# sudo yum install

Now with the repository installed, I can proceed to install Python 3.6:

[root@local ~]# sudo yum install python36u

Now it’s time to check the Python version with (should return Python 3.6.1 at the time of writing):

[root@local ~]# python3.6 -V

Next up, is pip to manage Python packages, and some development packages.

[root@local ~]# sudo yum install python36u-pip
[root@local ~]# sudo yum install python36u-devel

Ready to Test :

# This should return the system Python version
python –V
# output:
Python 2.7.5

# This should return the Python 3 version
python3.6 –V
# output:
Python 3.6.1

That’s it. Now I have Python 3.6 ready torun my apps!

Creating a virtualenv

The preferred thanks to produce a brand new virtualenv in Python three is to run (in your project directory):

[root@local ~]# python3.6 -m venv venv

.... where the previous venv is that the command to make a virtualenv, and therefore the latter venvis the name of the virtualenv.

To activate the virtualenv and start installing packages with pip:

[root@local ~]# . venv/bin/activate
[root@local ~]# pip install [package_name]
[root@local ~]# pip install -r requirements.txt