I'm trying to get back into python, working on a unix system. I'm trying to understand virtual environments, to keep all my packages organized, and am struggling with the difference between conda environments localized in a project directory with a /.conda/ subdirectory, and conda environments that live in conda_intallation_folder/envs/
I was reading the VSCode docs on venvs and understand the following:
A virtual environment creates a folder that contains a copy (or symlink) to a specific interpreter. When you install packages into a virtual environment it will end up in this new folder, and thus isolated from other packages used by other workspaces.
My question is specifically about the difference between conda enviroments that could be created with
conda create -n ENV_NAME python=PYTHON_VERSION
which I understand I would have to activate, with
conda activate env_name_or_prefix
and the conda environments I created through VSCode's Command Pallet, choosing Select Interpreter --> create virutal environment, which creates the local /.conda/ subdirectory.
I understand that both of these operations create an isolated interpreter with a unique set of packages.
I want to better understand the difference between these two approaches to creating the isolated interpreter, so I can make sure I'm accessing the environment I want and not accidentally tossing everything into global. Many thanks!
My question was asking about difference between two approaches to creating a virtual environment
The first approach, using VSCode's GUI, creates a local hidden folder /.conda
, which contains an isolated python interpreter at /.conda/bin/python
. Creating a conda environment this way is the same as using the command conda create -n environmentName -p path/to/dir
, and the environment's unique interpreter can be used to run a .py
file with path/to/dir/.conda/bin/python fileName.py
The difference between this approach and using conda create -n environmentName
is only that this command puts the .conda
folder in condaInstallFolder/anaconda3/envs
by default, and conda activate envName
is a utility which simply calls the python interpreter at condaInstallFolder/anaconda3/envs/environmentName/python
.