Как понизить версию python linux
Перейти к содержимому

Как понизить версию python linux

  • автор:

How To Downgrade Python

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.

How To Downgrade Python

On Windows:

  • Open a command prompt (“cmd”) and type pip install virtualenv into the command window.
  • Install the Python version you want from here; remember not to include it in your PATH environment variable.
  • Enter virtualenv path\to\env -p \path\to\python_install.exe into 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.

Alternate Option

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.

For Linux Users:

  • 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:
Clone the GitHub repository to get latest pyenv version:\
Set Environment Variables
Restart Shell Terminal
Check Required Python Version
Installing Required Python Version
Set Global Environment Variable

Changing it on a global scale (you can also go ahead and only use it in a certain environment)

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.

Wrap Up

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.

If you liked the above tutorial then please follow us on Facebook and Twitter. Let us know the questions and answer you want to cover in this blog.

Lower the Python3 version

I’m using Ubuntu 20.04 and default Python3 version is 3.8.2 but I want to use the Python 3.7.6 .
I don’t care if the Python 3.8.2 will be uninstalled or not. I only want to make sure every time I use python3 command it runs the Python 3.7.6 (instead of 3.8.2).
What should I do?

mhn2's user avatar

1 Answer 1

Don’t mess with, remove or replace the preinstalled Python interpreters!

The easiest option for Ubuntu LTS releases is to add the deadsnakes PPA which provides the latest of each minor Python version (3.6.x, 3.7.x, 3.8.x, . ) as regular packages, so it integrates well with your system. Once installed, you can call those versions with the python3.6 etc. command instead of plain python3 .

Alternatively, you can use e.g. pyenv to manage multiple independent interpreter versions for your development projects. Find it here, or use the simple installer. This gives you more flexibility and control, but is also a bit more effort and complex IMO.

Yet another possibility would be to use a containerization technology such as Docker to have always the same, reproducible and isolated build and run environments for your development.

Besides though, most not too special Python 3 code is compatible with newer interpreters, unless you use specifically deprecated methods and features. It’s always good to keep testing your projects against newer releases and adapt/fix them as needed to keep them alive.

How to downgrade python version in Ubuntu 20.04?

I need to change my python version from 3.8 to 3.6 ? How can I achieve this in Ubuntu 20.04. I tried pyenv, but when I try to use pyenv like pyenv global 3.6.0 then I do python3 and I have still 3.8 verision.

Brokolicový Džuß's user avatar

2 Answers 2

Do not downgrade the system version: it’s likely that some parts of the system would stop working. Never change /usr/bin/python3 , and avoid putting an older version of python3 before it in the $PATH .

The deadsnakes archive provides packages of most supported Python versions for currently supported Ubuntu LTS versions. To make these packages available, follow the usual instructions to enable a PPA. Then install the package(s) you want.

You can then create a virtual environment for your chosen Python version and with a chosen set of packages.

To run a program in this environment, source the bin/activate script in a shell.

Gilles 'SO- stop being evil''s user avatar

Alternatively, you can create a virtual environment.

Suppose you have python 3.8 (or higher) installed on the system, but for a specific task, you need python 3.7 (or lower). The best idea is (not to downgrade) to Create a virtual environment with python 3.7(or any 3.x, change the commands below according to your desired version. Below is an implementation of a virtual environment with python 3.7)

Steps: (Checked August 2022)

Install python 3.7 and it’s virtual environment packages.

sudo apt-get install python3.7-dev python3.7-venv

NB: If you’ll get errors like: E: Couldn’t find any package by glob ‘python3.7’ , stating that the packages can not be installed.

run the following commands below, then re-run the install command above:

sudo apt install software-properties-common

sudo add-apt-repository ppa:deadsnakes/ppa

Find out where your python 3.7 is located by this command:

which python3.7 (Should be something like /usr/bin/python3.7, if not found, then install python 3.7 manually)

Create Virtual Environment in the Home directory.

/usr/bin/python3.7 -m venv

python —version (Should be python 3.7 now)

Done. Python 3.7 can be used in this virtual environment. Type which python , you’ll see you have created python 3.7 in a virtual environment, rather than in the system globally.

Change Python Version in Pipenv

A recent upgrade to Ubuntu 20.04 messed up one of my projects which depended on python3.7 and I had to switch over to a higher version, however, it took a lot of googling, trial and error before I figured out how to make the switch in Pipenv.

Here’s a step by step guide on how to do this:

1. Change the “python_version” variable in your Pipfile to the new version you want. In my case it was
python_version = “3.8”

2. Open your terminal and run
pipenv install —python=/path/to/your/python

This would remove the previous virtual environment and create a new one using the python version specified.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *