Installing Python 3.8.12 - Ubuntu 20.04.4
(source pages : https://tecadmin.net/install-python-3-8-ubuntu/ , https://docs.python.org/3/tutorial/venv.html )
Introduction
BellaDati IoT Advance Analytic framework makes possible utilize Machine Learning concepts. There is a possibility to include scripts programmed in Python.
Python is a popular programming language. Besides web and software development, Python is used for data analytics, machine learning, and even design.
BellaDati except of ML offers also tool IDE (stands for Integrated Development Environment ) usable for editing , checking python language scripts.
The description below illustrates how install Python , pip, pylint and modules required for script running.This procedure have been used for specific BellaDati project with python scripts in use.
Recommendation
Python 3.8.12 ( and higher) is recommended and tested
Prerequisite
- sudo apt-get install build-essential checkinstall
- sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \
libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
Installing Python 3.8.12 from source code
- check version installed as default
python3 —version
response: Python 3.8.10
- use directory e.g. /opt for new installation and get source code
cd /opt
sudo wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz
- extract source archive file
sudo tar xzf Python-3.8.12.tgz
- compilation ( the process takes several minutes)
cd Python-3.8.12
./configure --enable-optimizations
make install
- server rebooting
reboot
- checking installed version
python3.8 —version
response: Python 3.8.12
rm /opt/Python-3.8.12.tgz ( removing to save storage space)
Upgrading pip
( pip - A tool for installing and managing Python packages)
/usr/local/bin/python3.8 -m pip install --upgrade pip
- check version installed
/usr/local/bin/python3.8 -m pip --version
response:
pip 22.3 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
Installing pylint and pyflakes
(pylint - code analysis for Python, pyflakes is a simple program which checks Python source files for errors.))
- find where python3.8 located
which python3.8
response: /usr/local/bin/python3.8
cd /usr/local/bin
- see directory contents
ls -all
response: python3.8, isort... pip3.8 and many files
- installing pylint
python3.8 -m pip install pylint
- checking location
which pylint
response : /usr/local/bin/pylint
- checking pylint version
pylint —version
response :
pylint 2.15.5
astroid 2.12.12
Python 3.8.12
- installing pyflakes
( the prcedure is the same as for pylint)
python3.8 -m pip install pyflakes
which pyflakes
pyflakes version
response : 2.5.0 Python 3.8.12 on Linux
Installing some module(s)
(required by used specific python script(s))
In this example - specific BellaDati project using Python script The script asked for several modules. The IDE have been used to see errors/warning . The modules needed can be added this way.
- checking modules already available
python3.8 -m pip list
response:
Package Version
----------------- -------
astroid 2.12.12
dill 0.3.6
isort 5.10.1
lazy-object-proxy 1.8.0
mccabe 0.7.0
pip 21.1.1
platformdirs 2.5.2
pylint 2.15.5
setuptools 56.0.0
tomli 2.0.1
tomlkit 0.11.5
typing-extensions 4.4.0
wrapt 1.14.1
- example: installing module "pandas"
/usr/local/bin/python3.8 -m pip install pandas
response :
Collecting pandas
Downloading pandas-1.5.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.2 MB)
Collecting python-dateutil>=2.8.1
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting numpy>=1.20.3
Downloading numpy-1.23.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
Collecting pytz>=2020.1
Downloading pytz-2022.6-py2.py3-none-any.whl (498 kB)
Collecting six>=1.5
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, pytz, python-dateutil, numpy, pandas
Successfully installed numpy-1.23.4 pandas-1.5.1 python-dateutil-2.8.2 pytz-2022.6 six-1.16.0
- the same step with e.g. module sklearn , wheel etc.
- Checking modules available now:
/usr/local/bin/python3.8 -m pip list
response:
Package Version
----------------- -------
astroid 2.12.12
dill 0.3.6
isort 5.10.1
joblib 1.2.0
lazy-object-proxy 1.8.0
mccabe 0.7.0
numpy 1.23.4
pandas 1.5.1
pip 22.3
platformdirs 2.5.2
pylint 2.15.5
python-dateutil 2.8.2
pytz 2022.6
scikit-learn 1.1.3
scipy 1.9.3
setuptools 56.0.0
six 1.16.0
sklearn 0.0
threadpoolctl 3.1.0
tomli 2.0.1
tomlkit 0.11.5
typing_extensions 4.4.0
wheel 0.37.1
wrapt 1.14.1
- Packages location:
cd /usr/local/lib/python3.8/site-packages