Environments

VS Code Workspace

A Visual Studio Code workspace is the collection of one or more folders that are opened in a VS Code window (instance).

The concept of a workspace enables VS Code to:

  • Configure settings that only apply to a specific folder or folders but not others.

  • Persist task and debugger launch configurations that are only valid in the context of that workspace.

  • Store and restore UI state associated with that workspace (for example, the files that are opened).

  • Selectively enable or disable extensions only for that workspace.

Note: It is also possible to open VS Code without a workspace. For example, when you open a new VS Code window by selecting a file from your platform's File menu, you will not be inside a workspace. In this mode, some of VS Code's capabilities are reduced but you can still open text files and edit them.

Making a VS Code Workspace

The easiest way to open a workspace is using the File menu and selecting one of the available folder entries for opening. Alternatively if you launch VS Code from a terminal, you can pass the path to a folder as the first argument to the code command for opening.

Python Environments

An environment in Python is the context in which a Python program runs and consists of an interpreter and any number of installed packages.

Global environments

By default, any Python interpreter installed runs in its own global environment. If you run python at a new terminal, you are running the interpreter's global environment. Any packages that you install or uninstall affect the global environment and all programs that you run within it.

Local Environments

There are two types of environments that you can create for your workspace: virtual and conda environments. Both types of environment allow you to install packages without affecting other environments. This lets you isolate what packages you install for your workspace so that they don't interfere with your needs in another workspace.

Virtual Environment

A virtual environment is a built-in way to create an environment to isolate the packages you install per workspace. 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 so that they are not interspersed with other packages used or needed by other workspaces.

Conda Environment

A conda environment is a Python environment that's managed using the conda package manager. Whether to use a conda environment or a virtual one will depend on your packaging needs, what your team has standardized on, etc. Download and install Anaconda from here.

Quick Commands VS Code Windows

create a conda environment

To create a conda environment using its name, use this command in terminal:

Note: It is better to include a . in the name of conda environment to set them apart from an ordinary folder (example : .myenv)

By default, environments are installed into the envs directory in conda base directory. To create an environment in any other locations, use the --prefix method which specifies the destination for environment creation.

An environment needs to be activated in terminal, in order to be accessible for installing or using python packages. if an environment is create by its name, it can be activated in using:

Remember: When a conda environment is created using --prefix method, it cant be activated using its name (like above). It should be activated using its destination:

Tip: There is a way around, to simply activate a conda environment using its name, when it is created by prefix. Look.

list and information of conda environments

In windows, open command line as an administrator, type in:

In the environments list that displays, your current environment is highlighted with an asterisk (*).

Last updated