In this tutorial, you will learn how to downgrade Python from your current version to the lower version.
You can easily downgrade your Python version if you are using a visual editor such as Anaconda or Visual Studio.
You will need to make sure that you have PIP installed on your computer and also have
virtualevn installed on your computer as well.
How To Downgrade Python
virtualevn Allows you to have multiple versions of the Python installed on your system. To downgrade Python or install multiple Python follow the below-mentioned steps.
- Open a command prompt (“cmd”) and type
pip install virtualenvinto the command window.
- Install the Python version you want from here; remember not to include it in your PATH environment variable.
virtualenv path\to\env -p \path\to\python_install.exeinto the command prompt, where \path\to\env will be the path where your virtual environment will be located and path\to\python_install.exe will be the path where your newly (presumably) installed Python version will be located. 4.
- A virtual environment has now been created for you. After that, to activate the virtual environment, run the activate.bat batch file, which can be found in the path to the virtual environment’s scripts folder. This website or an official Python guide.
Alternatively, you may choose to uninstall the version of the software that you are currently using from the installed program’s options. Then, from the official Python website, download the version of Python that you want to use and install it on your computer.
Ensure that you have set all of the environment Path variables for the newly installed Python version so that you can access the Python from anywhere in your program’s source code.
Uninstalling Python can be accomplished by going to Control Panel -> “Uninstall a program,” searching for “Python,” right-clicking the Python name, and selecting “Uninstall.” Keep in mind that Python typically has a PATH variable stored, so you should also remove it from the environment.
For HomeBrew Users:
Homebrew is a software package management system that can be used to downgrade the Python version on your Linux operating system. Follow the below code to install the required Python Version. In the below example I have installed version 3.9.0 by uninstalling Python version 3.10.2.
$ brew unlink python $ brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/e128fa1bce3377de32cbf11bd8e46f7334dfd7a6/Formula/python.rb $ brew switch python 3.9.0
For Linux Users:
To downgrade the Python version on the Linux operating system you may need to follow the below steps:
- To begin, download the desired Python version from the official Python website and install it as if it were a normal package on your computer.
- Then execute the following code: cd /Library/Frameworks/Python.framework/Version
- Now, To see a list of all the Python versions that are currently installed, run the command ls.
- Then run
sudo rm -rf 3.8(Note here you can enter the version you want to remove instead of 3.8) to remove the Python version from your System.
- After you’ve done all of that, run python3 -v. It will display the version of the software you selected to install.
For Mac Users:
You can use the Homebrew option on your macOS operating system. To install Homebrew follow the below steps and then further to uninstall unwanted and install the required version of Python from your macOS operating system.
Installing pyenv With HomeBrew:
brew update brew install pyenv
Clone the GitHub repository to get latest
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
Set Environment Variables
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
Restart Shell Terminal
Check Required Python Version
pyenv install --list
Installing Required Python Version
pyenv install 3.7
Set Global Environment Variable
Changing it on a global scale (you can also go ahead and only use it in a certain environment)
pyenv global 3.7
Check the Python version that is currently being used by the system – your desired/downgraded version should appear here.
For Anaconda Users:
If you are using the Anaconda software to run a Python program and you want to set the Python version to a lower version than the one that is currently in use, then enter the code below in the Anaconda Terminal and hit enter.
conda install python=3.10.2 # or maybe conda install python=3.7.0 # or whatever you want....
On any of the environments listed above, I hope you were successful in downgrading Python to the required version that you desired.
If you are still unable to downgrade Python on your system, please let me know in the comments section and I will be happy to assist you as soon as possible.