When Python downgrades, it does not necessarily require complete uninstallation of Python version 3.12. You can choose to install a lower version of Python directly (such as 3.8 or 3.9), and then use some methods to switch versions or create a virtual environment to avoid conflicts. Here are two common methods:
Method 1: Install the lower version of Python directly (not uninstalling 3.12)
You can install multiple Python versions simultaneously on your system without uninstalling the existing Python 3.12 version. You can then select the version you want to use using:
Download and install lower versions of Python (e.g. 3.9):
- VisitPython official websiteDownload the appropriate Python version (for example, 3.9).
- When installing, make sure the "Add Python to PATH" option is checked.
Set the default Python version: After installing multiple versions, the system may use Python 3.12 by default, but you can specify the version of Python in the following ways:
On Linux/macOS systems, you can use the commandTo specify the version to use:
python3.9 --version # View Python 3.9 versionpython3.9 -m pip install pyradiomics # Install pyradiomics using Python 3.9
On Windows systems, you can modify system environment variablesPATH
To adjust the default Python version, or throughpy
Command to specify different versions of Python:
py -3.9 --version # Using Python 3.9py -3.9 -m pip install pyradiomics # Install pyradiomics using Python 3.9
Method 2: Use virtual environment to manage different versions (recommended)
A virtual environment allows you to use multiple Python versions simultaneously on the same machine and configure an independent environment for each project without interfering with the system's global Python settings. This way, even if you have Python 3.12 installed, you can use Python 3.9 in a virtual environment.
Install lower version of Python (if not installed): If you don't have the Python version you want (for example, 3.9) on the system, you can download and install it according to the steps in Method 1.
Create a virtual environment: usepyenv
(Recommended) orvenv
Create a virtual environment and select a lower version of Python.
usepyenv
Create a virtual environment (recommended):
If you installedpyenv
, it is easy to install multiple Python versions and create a virtual environment:
pyenv install 3.9.7 # Install Python 3.9.7pyenv virtualenv 3.9.7 pyradiomics-env # Create a new virtual environmentpyenv activate pyradiomics-env # Activate the virtual environmentpython -m pip install pyradiomics # Install pyradiomics
usevenv
Create a virtual environment (no dependence on additional tools):
If you have Python 3.9 installed, you can create a virtual environment directly:
python3.9 -m venv pyradiomics-env # Create a virtual environmentsource pyradiomics-env/bin/activate # Activate the virtual environment (Linux/macOS)pyradiomics-env\Scripts\activate # Activate the virtual environment (Windows)pip install pyradiomics # Install pyradiomics
Activate the virtual environment and use it: Every time you use this virtual environment, you only need to activate it. After that, all Python packages and dependencies will be installed and used in the virtual environment and will not affect other Python environments of the system.
Summarize:
- You don't need to uninstall Python 3.12, you can directly install the lower version of Python.
- Recommended use of virtual environments (such as
pyenv
orvenv
), you can manage multiple Python versions on the same machine without modifying the global Python version of the system. This way you can choose different Python versions for different projects to avoid version conflicts.
This is the end of this article about the two implementation methods of Python downgrade. For more related Python downgrade content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!