Configuring python environments in visual studio code electricity history timeline

The Python extension relies on a Python environment (an interpreter and installed packages) for IntelliSense, auto-completions, linting, formatting, and any other language-related features other than debugging. The selected environment is also automatically activated when using the Python: Run Python File in Terminal and Python: Create Terminal commands.

Note: By default, the Python extension looks for and uses on the first Python interpreter it finds in the system path. If it doesn’t find an interpreter, it issues a warning. On macOS, the extension also issues a warning if you’re using the OS-installed Python interpreter, because you typically want to use an interpreter you install directly. In either case, you can disable these warnings by setting python.disableInstallationCheck to true in your user settings. How to choose an environment

This command automatically looks for and displays a list of available Python interpreters, conda environments, and virtual environments. (See Where the extension looks for environments in a later section.) The following image, for example, shows several Anaconda and CPython installations along with one conda environment:

Note: On Windows, it can take a little time for VS Code to detect available conda environments. During that process, you may see "(cached)" before the path to an environment. The label indicates that VS Code is presently working with cached information for that environment.

When an environment is activated in the terminal, any changes you make to the environment within the terminal are persistent. For example, using conda install from the terminal with a conda environment activated installs the package into that environment permanently. Similarly, using pip install in a terminal with a virtual environment activated adds the package to that environment.

Note: Launching VS Code from a shell in which a certain Python environment is activated does not automatically activate that environment in the default Terminal. Use the Python: Create Terminal command after VS Code is running. Choose a debugging environment

Although selecting a different environment changes the python.pythonPath value in your Workspace settings.json file, it doesn’t affect the User settings file, which is used by default for debugging. To use a different interpreter for debugging, set the value for pythonPath in the debugger settings launch.json file. See Debugging. Conda environments

A conda environment is a Python environment that’s managed using the conda package manager (see Getting started with conda ( Conda works very well to create environments with interrelated dependencies as well as binary packages. Unlike virtual environments, which are scoped to a project, conda environments are available globally on any given computer. This availability makes it easy to configure several distinct conda environments and then choose the appropriate one for any given project.

In contrast, the following command creates a conda environment with a the Python 3.4 interpreter and several libraries. Because the environment contains an interpreter (which you can see in the Anaconda envs/env-01 folder created by this command), VS Code includes it in its list: conda create -n env-01 python=3.4 scipy=0.15.0 astroid babel

By default, the Python extension loads a file named .env in the current workspace folder, as identified by the default value of the python.envFile setting (see General settings). You can change the python.envFile setting at any time to use a different definitions file.

A debug configuration also contains an envFile property that also defaults to the .env file in the current workspace (see Debugging – standard configuration and options). This property allows you to easily set variables for debugging purposes that replace those used in the default .env file.

For example, when developing a web application, you might want to easily switch between development and production servers. Instead of coding the different URLs and other settings into your application directly, you could use separate definitions files for each. For example: