Here in this article sharing with you how to install python in Ubuntu 22.04 LTS. First you have to turn on your terminal on your Ubuntu and type there:
Run the command and check you will see Python3 by default pcomes with your Ubuntu 22.04 LTS. To check the install version is Python3 run this command.
How to Install python-is-python3 On Ubuntu 22.04 LTS
Run the following command to install “python-is-python3” package on Ubuntu 22.04 LTS. This package redirects Python to Python3 by creating a symbolic link of Python3 for Python.sudo apt install python-is-python3
Run the following command to verify the availability of the default Python3:python3 –version
How to Uninstall Python From Ubuntu 22.04 LTS?
sudo apt remove python3
How to Install a Different Version of Python From Source On Ubuntu 22.04 LTS?
First, run the following command to install the required dependencies on Ubuntu.
- sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev
Now, download the required Python package with the following command:
- wget https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tgz
Now, run the following command to extract the Python Source Files:
- tar -xvf Python-3.11.1.tgz
After extracting Python, run the following command to configure Python:
- cd Python-3.11.1 ./configure–enable-optimizations
Compile the source file:
Now, it’s time to install Python with the following command:sudo make altinstall
After all this steps, run the following command to check the version of Python:python3.11 –version