When should we Downgrade the version of Python:
Note: The latest version of "Ubuntu 22.04, Ubuntu 20.04, Ubuntu 18.04" comes with the latest version of "Python 3.10, Python 3.9 and Python 3.8". If we are already working on projects that support older Python versions and packages, moving to the latest version of Python may cause some problems, such as package dependency errors or other issues. Basically, Python3.6 is the default version in Ubuntu 18.04, Python 3.8 is the default version in Linux Ubuntu 20.04, and Python 3.10 is the default version in Linux Ubuntu 22.04.
We can change any version of Python by following the steps outlined below. In this tutorial, we will switch from Python3.8 to Python3.6. Remember that all steps work the same way if you want to downgrade or upgrade "ANY" Python version.
Also Read: How to set up Github to clone the Python Django project Repo.
1. Downgrade Python in Linux Ubuntu OS:
(Part A): Change Universal Python Version Manually.
Step 1: Download the required Python version:
tom@hp~$ cd /usr/src tom@hp:/usr/src$ wget https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz
Note:
Replace whatever Python version that you want to install and make sure the version must be accurate otherwise it will arise an error. Check the Python version release from the official python release for more accuracy.
Ex: Replace /3.6.15/ with /3.8.15/ or /3.7.15/ or /3.x.xx/,
and
Python-3.6.15.tgz with Python-3.8.15.tgz or Python-3.7.15.tgz or Python-3.x.xx.tgz
Example: $ wget https://www.python.org/ftp/python/3.7.15/Python-3.7.15.tgz
Step 2: Extract the Downloaded .tar file. If you have downloaded another version so just replace the version:
tom@hp:/usr/src$ sudo tar xzf Python-3.6.15.tgz
Step 3: Now, Check downloaded Python 3.6.15 located inside the path "/usr/src"
tom@hp~$ cd /usr/src tom@hp:/usr/src $ ls Python-3.6.15.tgz Python-3.6.15
Step 4: Install Required Packages (Copy all at once and paste in terminal):
tom@hp~$ sudo apt-get install build-essential checkinstall \ libreadline-gplv2-dev libncursesw5-dev libssl-dev \ libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Step 5: Install Python on System:
tom@hp~$ cd /usr/src tom@hp:/usr/src $ ls Python-3.6.15.tgz Python-3.6.15 tom@hp:/usr/src $ cd Python-3.6.15/ tom@hp:/usr/src/Python-3.6.15$
Step 6: Step 6: Run Configure Script:
tom@hp:/usr/src/Python-3.6.15$ tom@hp:/usr/src/Python-3.6.15$ sudo ./configure
Step 7: Run Package Bilder:
tom@hp:/usr/src/Python-3.6.15$ sudo make altinstall
Step 8: Now, Check installed Python3.6 located inside the path "usr/local/bin" repository:
tom@hp:/usr/src/Python-3.6.15$ cd /usr/local/bin/ tom@hp:/usr/local/bin $ ls 2to3-3.6 idle3.6 pydoc3.6 python3.6m pyvenv-3.6 easy_install-3.6 pip3.6 python3.6 python3.6m-config tom@hp:/usr/local/bin$ python3.6 Python 3.6.15 (default, Dec 7 2021, 13:04:41) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 5+5 10 >>>
(Part B): Setup New install Python3.6.15 as the default version.
NoteGreate Work!, Now suppose that earlier you had installed python3.8 in your system, so
it will again open python3.8 version by default in the new terminal,
not the recently downloaded version. To open Python3.6.15 recently
changed version as default, we have to point the python file in
"/usr/local/bin" directory which is currently located inside this path
"usr/bin/" directory.
Let's Do it.
Step 1: Go to /usr/bin/ Directory:
tom@hp~$ cd /usr/bin/
Step 2: Check which compiler version pointing by the < Python > interpreter:
tom@hp:/usr/bin/$ ls -lrth python* lrwxrwxrwx 1 root python2 -> python2.7 lrwxrwxrwx 1 root python-config -> python2-config lrwxrwxrwx 1 python2.7-config -> x86_64-linux-gnu-python2.7-config -rwxr-xr-x 1 root root python2.7 lrwxrwxrwx 1 python3.8-config -> x86_64-linux-gnu-python3.8-config -rwxr-xr-x 1 root root python3.8 lrwxrwxrwx 1 root python3 -> python3.8 lrwxrwxrwx 1 root root python -> /usr/bin/python3.8 tom@hp:/usr/bin/$ tom@hp:/usr/bin/$
Step 3: Unlink Python that is pointing to the Python3.8 version:
tom@hp: /usr/bin/$ sudo unlink python tom@hp:/usr/bin/$ tom@hp:/usr/bin/$ ls -lrth python* lrwxrwxrwx 1 root python2 -> python2.7 lrwxrwxrwx 1 root python-config -> python2-config lrwxrwxrwx 1 python2.7-config -> x86_64-linux-gnu-python2.7-config -rwxr-xr-x 1 root root python2.7 lrwxrwxrwx 1 python3.8-config -> x86_64-linux-gnu-python3.8-config -rwxr-xr-x 1 root root python3.8 tom@hp:/usr/bin/$ tom@hp:/usr/bin/$
Step 4:Now create a new python interpreter file that will Link to the recently downloaded python Compiler:
tom@hp:/usr/bin/$ cd /usr/local/bin tom@hp:/usr/local/bin/$ sudo ln -s /usr/local/bin/python3.6 python
Step 5: Now python will open Python3.6 as the default downloaded version. Open a new terminal and just type python:
tom@hp:~$ python Python 3.6.15 (default, Dec 7 2021, 13:04:41) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 15+5 20 >>>
NoteIf you need to use an earlier Python version, repeat the process in reverse order. In other words, you must first unlink the python file that is now pointing to the Python3.6 version in this article. After unlinking the python file from the " usr/local/bin " directory, create a new python file that points to the previous python3.8 version. Refer to Steps 3–5 in detail.
Learn how to set up Github to clone the Django project Repo.
Dear, if you encounter any difficulties in the preceding steps, Kindly leave a comment and our team will assist you as soon as possible.
FAQ:
How to Downgrade Python version Using Conda Command in Anaconda.
How to Downgrade Python version Using Conda Command in Anaconda.
conda install python=3.5.0
How to Downgrade Python version in
Windows 10,8, and 7.
For Windows 10, 8, 7 users':
How to Create Virtual Environment For Python Project.
How to Create Virtual Environment For Python Project.
Step1. Download Virtual Environment using the python package
manager.
Option 1
$ sudo apt install python3-venv
Option 2
$ pip --version
$ pip install virtualenv # use this command if pip
points already Python3
or
$ pip3 install virtualenv # use this if pip points
Python2
Step2. Create Virtual Environment.
$ python -m venv my_env
or
$
python3 -m venv my_env
Step3. Activate Virtual Environment
tom@hp~$ source Env_Name/bin/activate
# Note: In my case, I have install Python on my Home directory. But if you have created virtual environnment in other director, so you have to go in that path where your virtual environment created.
How to install Django in a virtual environment in Ubuntu 18.04/ Ubuntu
20.04.
How to install Django in a virtual environment in Ubuntu 18.04/
Ubuntu 20.04.
Step 1. Install pip, pip is a Python Package manager.
# install pip3, if it is not pre installed.
sudo apt-get -y install python3-pip
Step2. Install Django.
pip3 install django # For Download Latest version
of Django.
or
pip3 install
Django==version # Ex: Django==2.2.24 /for
Download specific Version
or
python
- m pip install Django
or
pip install
django
How to install Django Using Conda command in Anaconda.
How to install Django Using Conda command in Anaconda.
(env) tom@hp~$ conda install -c anaconda django
# Installing specific versions of conda packages by using
(env) tom@hp~$ conda install package-name=2.3.4
Optional
update - alternatives--install / usr / bin / python python / usr / bin / python3 1
Once all installation is completed, make the 'pip3' command as
the default 'pip' version.
update - alternatives--install / usr / bin / pip pip / usr / bin / pip3 1
How to Downgrade Python version Using Conda Command in Anaconda.
How to Downgrade Python version Using Conda Command in Anaconda.
How to Downgrade Python version in
Windows 10,8, and 7.
Windows 10,8, and 7.
For Windows 10, 8, 7 users':
How to Create Virtual Environment For Python Project.
How to Create Virtual Environment For Python Project.
Step1. Download Virtual Environment using the python package manager.
Option 1
$ sudo apt install python3-venv
Option 2
$ pip --version
$ pip install virtualenv # use this command if pip
points already Python3
or
$ pip3 install virtualenv # use this if pip points
Python2
Step2. Create Virtual Environment.
$ python -m venv my_env
or
$
python3 -m venv my_env
Step3. Activate Virtual Environment
tom@hp~$ source Env_Name/bin/activate # Note: In my case, I have install Python on my Home directory. But if you have created virtual environnment in other director, so you have to go in that path where your virtual environment created.
How to install Django in a virtual environment in Ubuntu 18.04/ Ubuntu 20.04.
How to install Django in a virtual environment in Ubuntu 18.04/ Ubuntu 20.04.
Step 1. Install pip, pip is a Python Package manager.
# install pip3, if it is not pre installed.
sudo apt-get -y install python3-pip
Step2. Install Django.
pip3 install django # For Download Latest version
of Django.
or
pip3 install
Django==version # Ex: Django==2.2.24 /for
Download specific Version
or
python
- m pip install Django
or
pip install
django
How to install Django Using Conda command in Anaconda.
How to install Django Using Conda command in Anaconda.
(env) tom@hp~$ conda install -c anaconda django
# Installing specific versions of conda packages by using
(env) tom@hp~$ conda install package-name=2.3.4
Optional
update - alternatives--install / usr / bin / python python / usr / bin / python3 1
Once all installation is completed, make the 'pip3' command as the default 'pip' version.
update - alternatives--install / usr / bin / pip pip / usr / bin / pip3 1