Score:1

Change conda environment to the preinstalled system Python version

cn flag

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?

Score:1
ca flag

What you observed is correct and is exactly how conda is supposed to work.

Using the commands conda activate my_env and conda install python=3.8 you first tell conda to activate the virtual environment named my_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.

Samuel Osoba avatar
cn flag
Thanks for the editing and answer. Regards.
BeastOfCaerbannog avatar
ca flag
You're welcome! :D
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.