Python is an interpreted high-level programming language for general-purpose programming. Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability, notably using significant whitespace
Install the necessary utilities
As all Linux tutorials out there, first thing is to install the updates. The I can proceed with the installation of the necessary tools and utilities.
sudo yum update sudo yum install yum-utils sudo yum groupinstall development
Now all of the necessary packages have been installed.
Install Python 3.6.1
The standard yum repositories does not yet provide the latest Python release, so I need to install an additional repository, called IUM (Inline with Upstream Stable), which provides the necessary RPM packages.
So, to install IUM repository:
sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Now with the repository installed, I can proceed to install Python 3.6:
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):
Next up, is pip to manage Python packages, and some development packages.
sudo yum install python36u-pip 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 way to create a new virtualenv in Python 3 is to run (in your project directory):
python3.6 -m venv venv
… where the former
venv is the command to create a virtualenv, and the latter
venvis the name of the virtualenv.
To activate the virtualenv and start installing packages with pip:
. venv/bin/activate pip install [package_name] pip install -r requirements.txt