I switched to Linux completely 4months ago. I have been able to install Anaconda in my Ubuntu 20.04, but I observed something which is like a headache.
After setting up an environment, I needed to change the Python version it uses from 3.10 to 3.8. So I used these commands:
conda activate my_env
conda install python=3.8
which is the standard way of doing it in Anaconda.
However, I observed that it downloaded new Python 3.8 packages into the environment, despite the fact that I had Python 3.8 already pre-installed on my system.
How do I configure my conda
environment to use the existing Python version already installed on my system without downloading a copy from the internet?
What you observed is correct and is exactly how
conda
is supposed to work.Using the commands
conda activate my_env
andconda install python=3.8
you first tellconda
to activate the virtual environment namedmy_env
and then install Python 3.8 in it.A virtual environment is an environment (think of it as a special folder) that is used to install Python (or another supported language), as well as packages and their dependencies, independently from the main OS. It has the big advantage that all packages installed in it won't affect the ones that come preinstalled with the OS, so they can be handled (updated, downgraded, removed, etc.) separately, effectively eliminating breakages of the main system due to unsatisfied dependencies, etc. In the case of Python specifically, this is one of the most common reasons that users end up with a broken system.
So, in your case in which you wanted to use Python 3.8 in
my_env
, Python 3.8 would have to be downloaded again, since, as said before, the environment's Python version is independent of the main OS's version. You cannot, or, better, you shouldn't, use the system's installation in your virtual environment, as this would defy the purpose of having a virtual environment in the first place and could easily lead to a broken system.