Hi,
In this post we are going to look at how to install Python and PIP and installing packages in virtual environments..
Without wasting any more time let dive into the topic...
Installing Python in Ubuntu
I am here assuming that you do not have prior installation of python...having assumed the case the installation of python is very straight forward.
> sudo apt update
> sudo apt upgrade
> sudo apt install python3
> sudo apt install python3-pip
> sudo apt install python-is-python3
The first two commands update and upgrades the ubuntu operating system, the third installs the python to be precise python3 and the one before last installs the python package manager.
The last command is for the simplication...i.e we do not have to type "python3" at the command line to have the python console rather the command "python" is enough
To confirm the installation use the following commands
> python3 --version
> pip3 --version
After having installed python and its package manager we may need to install certain packages that are required for some specific tasks during programming...
To perform those package installations we have to have virtual environment for python.
To create one follow the steps given below...
> sudo apt install python3-venv
the above command installs the packages required to create a virtual environment
Creating a Virtual Environment
> python3 -m venv <environment-name>
the above actually creates a virtual environment for the python packages, simply a directory in your preferred location.
Activating the Virtual Environment
> source <environment-name>/bin/activate
the above command is to activate the virtual environment, when we install a python package using pip, the package installed is made available only in this virtual environment.
De-Activating the Virtual Environment
> deactivate
Removing the Virtual Environment
> rm -rf <path-to-the-virtual-environment>/<virtual-environment-dir>
With this we have successfully installted python3...
Have great time reading... thanks.