Thursday, June 4, 2020

Install Python on Centos 7 Linux

Python is a programming language that can be used for:
  1. Back-end web application
  2. Desktop application
  3. Processing huge amount of data
  4. Control a computer
Example of a basic Python command:

print("Hello, world!")

Install Python

Pip is a tool to manage packages/libraries within Python. On Centos 7, the default pip is version 9.0.3 and it should be upgraded once python is installed.

Following are notes to install Python 3 on Centos 7 Linux. All these are at the command prompt.

sudo yum install python3  python3-devel

Check the installed version

python3 -V

Create directory for python projects

mkdir projects

cd projects

python3 -m venv my_env

Initiate the python project environment

source my_env/bin/activate

Create your first programme in a file called hello.py and save the following line.

print("Hello, World")

Run the programme.

python hello.py

Upgrade pip package manager.

pip install --upgrade pip

Once done with Python, leave the project environment.

deactivate


Extra pip example 

Install setuptools to install applications from source

pip install --upgrade setuptools wheel

Install Tensorflow application, then print its version

pip install --upgrade tensorflow
pip show tensorflow



No comments:

Blog Archive