Anaconda virtual environment changes python version

For example, I used to be python3.9, but now I want to change it to 3.5. There is a plan to execute it directly in the virtual environment:

conda install python=3.5

This is not feasible! ! ! Because this only changes the version of python, other packages have not been changed. But other packages depended on python3.9 at the beginning, and now python suddenly becomes 3.5, and the dependencies are messed up, and other packages have to be reinstalled. For example, package A was originally version 1.10, which supports python3.9, but now pyhton has become 3.5, and version A of version 1.10 does not support python3.5, so it cannot be used.

Summary: If you want to change the python version of a virtual environment, you can only create a new virtual environment and reinstall it. You cannot directly change the python version in the original virtual environment (unless you change all other packages according to the new python version, only Changing python is not acceptable)!

If you have executed conda install python=3.5, you can install the original python through conda install python=3.9, or restore the virtual environment by rolling back.

Reference: Repair the version of yijhon in the current conda env (conda environment) (upgrade or downgrade)

[Pit] To create a new virtual environment, you must specify the python version

When creating a new virtual environment in anaconda, if it is just conda create -n MyNew (without specifying the python version) , the creation will fail, and you will find that there are no packages in the new environment MyNew, and all the packages have been downloaded to the base, because there is no If python is specified, pip will point to pip in the base environment! !

Guess you like

Origin blog.csdn.net/m0_52848925/article/details/130909249
Recommended