From 07d20c67c13640d55fc40b2ded5087d022fd367f Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Thu, 19 Jan 2023 14:32:02 -0800 Subject: [PATCH 1/3] Clean up the environments documentation for Python --- docs/python/environments.md | 162 ++++++++++-------------------------- 1 file changed, 43 insertions(+), 119 deletions(-) diff --git a/docs/python/environments.md b/docs/python/environments.md index 26229d1d11..91e61d36c9 100644 --- a/docs/python/environments.md +++ b/docs/python/environments.md @@ -18,34 +18,38 @@ This article discusses the helpful Python environments features available in Vis ### Global environments -By default, any Python interpreter installed runs in its own **global environment**. They aren't specific to a particular project. For example, if you just run `python`, `python3`, or `py` at a new terminal (depending on how you installed Python), you're running in that interpreter's global environment. Any packages that you install or uninstall affect the global environment and all programs that you run within it. +By default, any Python interpreter installed runs in its own **global environment**. For example, if you just run `python`, `python3`, or `py` at a new terminal (depending on how you installed Python), you're running in that interpreter's global environment. Any packages that you install or uninstall affect the global environment and all programs that you run within it. -Working in the global environment is an easy way to get started. If you install packages in that environment, though, in time it will become crowded and make it difficult to properly test an application. +Do note that if you install packages into your global environment, though, in time it will become crowded with disparate packages and make it difficult to properly test an application. You typically want to create an environment for each workspace. -### Virtual environments +### Local environments -To prevent such clutter, developers often create a **virtual environment** for a project. A virtual environment is a folder that contains a copy (or symlink) of a specific interpreter. When you install into a virtual environment, any packages you install are installed only in that subfolder. When you then run a Python program within that environment, you know that it's running against only those specific packages. +There are two types of environments that you can create for your workspace: *virtual* and *conda* environments. Both types of environment provide a way to create an environment to install packages into. This lets you isolate what packages you install for your workspace so that they don't interfere with your needs in another workspace. + +#### Virtual environments + +A [**virtual environment**](https://docs.python.org/3/glossary.html#term-virtual-environment) is 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. > **Note**: While it's possible to open a virtual environment folder as a workspace, doing so is not recommended and might cause issues with using the Python extension. +#### Conda environments + +A **conda environment** is a Python environment that's managed using the `conda` package manager (see [Getting started with conda](https://conda.io/projects/conda/en/latest/user-guide/getting-started.html)). Whether to use a conda environment or a virtual one will depend on your packaging needs, what your team has standardized on, etc. + ### Python environment tools -Once you activate your virtual environment, you’ll need to identify how to manage it and its accompanying packages. The following table explains how to use these Python environments: +The following table lists the various tools involved with Python environments: | Tool | Definition and Purpose | | :---: | --- | -| pip | The Python package manager that installs and updates packages. It's installed with Python 3.9+ by default (install `python3-pip` on Debian-based OSs). | -| venv | Allows you to manage separate package installations for different projects and is installed with Python 3 by default (install `python3-venv` if you are using a Debian-based OS) | -| conda | Installed with **Anaconda** and **Miniconda**. It can be used to manage both packages and virtual environments. Generally used for data science projects. | +| [pip](https://pip.pypa.io/) | The Python package manager that installs and updates packages. It's installed with Python 3.9+ by default (unless you are on a Debian-based OS; install `python3-pip` in that case). | +| [venv](https://docs.python.org/3/library/venv.html) | Allows you to manage separate package installations for different projects and is installed with Python 3 by default (unless you are on a Debian-based OS; install `python3-venv` in that case) | +| [conda](https://docs.conda.io/) | Installed with [**Miniconda**](https://docs.conda.io/en/latest/miniconda.html). It can be used to manage both packages and virtual environments. Generally used for data science projects. | -### Conda environments -A **conda environment** is a Python environment that's managed using the `conda` package manager (see [Getting started with conda](https://conda.io/projects/conda/en/latest/user-guide/getting-started.html) (conda.io)). Whether to use a conda environment or a virtual one will depend on your packaging needs, what your team has standardized on, etc. ### How the extension looks for environments -If Visual Studio Code doesn't locate your interpreter automatically, you can [manually specify an interpreter](#manually-specify-an-interpreter). - If an interpreter hasn't been specified, then the Python extension automatically selects the interpreter with the highest version in the following priority order: 1. Virtual environments located directly under the workspace folder. @@ -54,6 +58,8 @@ If an interpreter hasn't been specified, then the Python extension automatically > **Note**: The interpreter selected may differ from what `python` refers to in your terminal. +If Visual Studio Code doesn't locate your interpreter automatically, you can [manually specify an interpreter](#manually-specify-an-interpreter). + ### Where the extension looks for environments The extension automatically looks for interpreters in the following locations, in no particular order: @@ -62,18 +68,16 @@ The extension automatically looks for interpreters in the following locations, i - Virtual environments located directly under the workspace (project) folder. - Virtual environments located in the folder identified by the `python.venvPath` setting (see [General Python settings](/docs/python/settings-reference.md#general-python-settings)), which can contain multiple virtual environments. The extension looks for virtual environments in the first-level subfolders of `venvPath`. - Virtual environments located in a `~/.virtualenvs` folder for [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/). -- Interpreters installed by [pyenv](https://github.com/pyenv/pyenv), [Pipenv](https://pypi.org/project/pipenv/), and [Poetry](https://poetry.eustace.io/). +- Interpreters created by [pyenv](https://github.com/pyenv/pyenv), [Pipenv](https://pypi.org/project/pipenv/), and [Poetry](https://poetry.eustace.io/). - Virtual environments located in the path identified by `WORKON_HOME` (as used by [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/)). - Conda environments found by `conda env list`. Conda environments which do not have an interpreter will have one installed for them upon selection. -- Interpreters installed in a `.direnv` folder for [direnv](https://direnv.net/) under the workspace (project) folder. - -The extension also loads an [environment variable definitions file](#environment-variable-definitions-file) identified by the `python.envFile` setting. The default value of this setting is `${workspaceFolder}/.env`. +- Interpreters installed in a `.direnv` folder for [direnv](https://direnv.net/) under the workspace folder. ## Creating environments ### Using the Create Environment command -From within VS Code, you can create non-global environments, using virtual environments or Anaconda, by opening the Command Palette (`kb(workbench.action.showCommands)`), start typing the **Python: Create Environment** command to search, and then select the command. +From within VS Code, you can create local environments, using virtual environments or Anaconda, by opening the Command Palette (`kb(workbench.action.showCommands)`), start typing the **Python: Create Environment** command to search, and then select the command. The command presents a list of environment types: **Venv** or **Conda**. @@ -91,43 +95,39 @@ After selecting the desired interpreter or Python version, a notification will s ![Create environment status notification](images/environments/create_environment_prompt_status.png) -> **Note**: The command will also install necessary packages outlined in a requirements/dependencies file, such as `requirements.txt`, `pyproject.toml`, or `environment.yml`, located in the project folder. +> **Note**: The command will also install necessary packages outlined in a requirements/dependencies file, such as `requirements.txt`, `pyproject.toml`, or `environment.yml`, located in the project folder. It will also add a `.gitignore` file to the virtual environment to help prevent you from accidentally committing the virtual environment to source control. ### Create a virtual environment in the terminal -To create a virtual environment, use the following command, where ".venv" is the name of the environment folder: +If you choose to create a virtual environment manually, use the following command (where ".venv" is the name of the environment folder): ```bash # macOS/Linux -# You may need to run sudo apt-get install python3-venv first +# You may need to run `sudo apt-get install python3-venv` first on Debian-based OSs python3 -m venv .venv # Windows -# You can also use py -3 -m venv .venv +# You can also use `py -3 -m venv .venv` python -m venv .venv ``` >**Note**: To learn more about the `venv` module, see [Creation of virtual environments](https://docs.python.org/3/library/venv.html) on Python.org. -When you create a new virtual environment, a prompt will be displayed to allow you to select it for the workspace. +When you create a new virtual environment, a prompt will be displayed in VS Code to allow you to select it for the workspace. ![Python environment prompt](images/environments/python-environment-prompt.png) -This will add the path to the Python interpreter from the new virtual environment to your workspace settings. That environment will then be used when installing packages and running code through the Python extension. For examples of using virtual environment in projects, see the [Python](/docs/python/python-tutorial.md), [Django](/docs/python/tutorial-django.md), and [Flask](/docs/python/tutorial-flask.md) tutorials. - -> **Tip**: When you're ready to deploy the application to other computers, you can create a `requirements.txt` file with the command `pip freeze > requirements.txt` (`pip3` on macOS/Linux). The requirements file describes the packages you've installed in your virtual environment. With only this file, you or other developers can restore those packages using `pip install -r requirements.txt` (or, again, `pip3` on macOS/Linux). By using a requirements file, you need not commit the virtual environment itself to source control. +> **Tip**: Make sure to update your source control settings to prevent accidentally committing your virtual environment (e.g. `.gitignore`). Since virtual environments are not portable it typically does not make sense to commit it for others to use. ### Create a conda environment in the terminal -The Python extension automatically detects existing conda environments. We recommend you install a Python interpreter into your conda environment, otherwise one will be installed for you after you select the environment. For example, the following command creates a conda environment with the Python 3.9 interpreter and several libraries, which VS Code then shows in the list of available interpreters: +The Python extension automatically detects existing conda environments. We recommend you install a Python interpreter into your conda environment, otherwise one will be installed for you after you select the environment. For example, the following command creates a conda environment named `env-01` with a Python 3.9 interpreter and several libraries: ```bash -conda create -n env-01 python=3.9 scipy=0.15.0 astroid babel +conda create -n env-01 python=3.9 scipy=0.15.0 numpy ``` -In contrast, if you fail to specify an interpreter, as with `conda create --name env-00`, the environment won't appear in the list. - -For more information on the conda command line, see [Conda environments](https://conda.io/docs/user-guide/tasks/manage-environments.html) (conda.io). +> **Note**: For more information on the conda command line, see [Conda environments](https://conda.io/docs/user-guide/tasks/manage-environments.html). Additional notes: @@ -137,23 +137,21 @@ Additional notes: - To ensure the environment is set up well from a shell perspective, one option is to use an Anaconda prompt with the activated environment to launch VS Code using the `code .` command. At that point you just need to select the interpreter using the Command Palette or by clicking on the status bar. -- Although the Python extension for VS Code doesn't currently have direct integration with conda environment.yml files, VS Code itself is a great YAML editor. +- Although the Python extension for VS Code doesn't currently have direct integration with conda `environment.yml` files, VS Code itself is a great YAML editor. - Conda environments can't be automatically activated in the VS Code Integrated Terminal if the default shell is set to PowerShell. To change the shell, see [Integrated terminal - Terminal profiles](/docs/terminal/profiles.md). -- You can manually specify the path to the conda executable to use for activation (version 4.4+). To do so, open the Command Palette (`kb(workbench.action.showCommands)`) and enter **Preferences: Open User Settings**. Then set `python.condaPath`, which is in the Python extension section of User Settings, with the appropriate path. +- You can manually specify the path to the `conda` executable to use for activation (version 4.4+). To do so, open the Command Palette (`kb(workbench.action.showCommands)`) and enter **Preferences: Open User Settings**. Then set `python.condaPath`, which is in the Python extension section of User Settings, with the appropriate path. -## Work with Python interpreters +## Working with Python interpreters ### Select and activate an environment -By default, the Python extension looks for and uses the first Python interpreter it finds in the system path. To select a specific environment, use the **Python: Select Interpreter** command from the **Command Palette** (`kb(workbench.action.showCommands)`). +As [mentioned earlier](#where-the-extension-looks-for-environments), the Python extension tries to find and then select what it deems the best environment for hte workspace. If you would prefer to select a specific environment, use the **Python: Select Interpreter** command from the **Command Palette** (`kb(workbench.action.showCommands)`). ![Python: Select Interpreter command](images/environments/select-interpreters-command.png) ->**Note**: If the Python extension 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](/docs/getstarted/settings.md). - -You can switch environments at any time; switching environments helps you test different parts of your project with different interpreters or library versions as needed. +>**Note**: If the Python extension doesn't find an interpreter, it issues a warning. On macOS 12.2 and older, the extension also issues a warning if you're using the OS-installed Python interpreter as it is known to have compatibility issues. In either case, you can disable these warnings by setting `python.disableInstallationCheck` to `true` in your user [settings](/docs/getstarted/settings.md). The **Python: Select Interpreter** command displays a list of available global environments, conda environments, and virtual environments. (See the [Where the extension looks for environments](#where-the-extension-looks-for-environments) section for details, including the distinctions between these types of environments.) The following image, for example, shows several Anaconda and CPython installations along with a conda environment and a virtual environment (`env`) that's located within the workspace folder: @@ -184,13 +182,13 @@ The Status Bar also reflects when no interpreter is selected. In either case, clicking this area of the Status Bar is a convenient shortcut for the **Python: Select Interpreter** command. -> **Tip**: If you have any problems with VS Code recognizing a virtual environment, please [file an issue](https://github.com/microsoft/vscode-python/issues) in the extension repository so we can help determine the cause. +> **Tip**: If you have any problems with VS Code recognizing a virtual environment, please [file an issue](https://github.com/microsoft/vscode-python/issues) so we can help determine the cause. ### Manually specify an interpreter If VS Code doesn't automatically locate an interpreter you want to use, you can browse for the interpreter on your file system or provide the path to it manually. -You can do so by running the **Python: Select Interpreter** command and clicking on the **Enter interpreter path...** option that shows on the top of the interpreters list: +You can do so by running the **Python: Select Interpreter** command and select the **Enter interpreter path...** option that shows on the top of the interpreters list: ![Enter interpreter path option on the interpreters list](images/environments/enter-interpreter-path.png) @@ -198,68 +196,20 @@ You can then either enter the full path of the Python interpreter directly in th ![Enter path or browse for an interpreter](images/environments/enter-or-find-interpreter.png) -If you want to manually specify a default interpreter that will be used once you first open your workspace, you can create or modify an entry for `python.defaultInterpreterPath` setting in your workspace `settings.json` with the full path to the Python executable. - -For example: - -- Windows: - - ```json - { - "python.defaultInterpreterPath": "c:/python39/python.exe", - } - ``` - -- macOS/Linux: - - ```json - { - "python.defaultInterpreterPath": "/home/python39/python", - } - ``` - -You can also use `python.defaultInterpreterPath` to point to a virtual environment, for example: - -- Windows: - - ```json - { - "python.defaultInterpreterPath": "c:/dev/ala/venv/Scripts/python.exe", - } - ``` - -- macOS/Linux: - - ```json - { - "python.defaultInterpreterPath": "/home/abc/dev/ala/venv/bin/python", - } - ``` +If you want to manually specify a default interpreter that will be used when you first open your workspace, you can create or modify an entry for `python.defaultInterpreterPath` setting. > **Note**: Changes to the `python.defaultInterpreterPath` setting are not picked up after an interpreter has already been selected for a workspace; any changes to the setting will be ignored once an initial interpreter is selected for the workspace. Additionally, if you'd like to set up a default interpreter to all of your Python applications, you can add an entry for `python.defaultInterpreterPath` manually inside your User Settings. To do so, open the Command Palette (`kb(workbench.action.showCommands)`) and enter **Preferences: Open User Settings**. Then set `python.defaultInterpreterPath`, which is in the Python extension section of User Settings, with the appropriate interpreter. -You can also use an environment variable in the path setting using the syntax `${env:VARIABLE}`. For example, if you've created a variable named `PYTHON_INSTALL_LOC` with a path to an interpreter, you can then use the following setting value: - - ```json - "python.defaultInterpreterPath": "${env:PYTHON_INSTALL_LOC}", - ``` - -> **Note**: Variable substitution is only supported in VS Code settings files, it will not work in `.env` environment files. - -By using an environment variable, you can easily transfer a project between operating systems where the paths are different, just be sure to set the environment variable on the operating system first. - ### Environments and Terminal windows After using **Python: Select Interpreter**, that interpreter is applied when right-clicking a file and selecting **Python: Run Python File in Terminal**. The environment is also activated automatically when you use the **Terminal: Create New Terminal** command unless you change the `python.terminal.activateEnvironment` setting to `false`. -However, launching VS Code from a shell in which a certain Python environment is activated doesn't automatically activate that environment in the default Integrated Terminal. Use the **Terminal: Create New Terminal** command after VS Code is running. +Please note that launching VS Code from a shell in which a certain Python environment is activated doesn't automatically activate that environment in the default Integrated Terminal. > **Note:** conda environments cannot be automatically activated in the integrated terminal if PowerShell is set as the integrated shell. See [Integrated terminal - Terminal profiles](/docs/terminal/profiles.md) for how to change the shell. -Any changes you make to an activated 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. - Changing interpreters with the **Python: Select Interpreter** command doesn't affect terminal panels that are already open. You can thus activate separate environments in a split terminal: select the first interpreter, create a terminal for it, select a different interpreter, then use the split button (`kb(workbench.action.terminal.split)`) in the terminal title bar. ### Choose a debugging environment @@ -268,21 +218,17 @@ By default, the debugger will use the Python interpreter you've selected with th For more details on debug configuration, see [Debugging configurations](/docs/python/debugging.md). -### Limited support for Python 2.7 - -The Python extension no longer offers IntelliSense support for Python 2.7 with [Jedi](https://pypi.org/project/jedi/) as it only supports Python 3 at this point. When using Python 2.7 with the Python extension you can customize the [language server setting](/docs/python/settings-reference.md#intellisense-engine-settings) to either turn off auto-completions or select Pylance as your language server, as it may provide a good experience if the code is compatible enough with Python 3. - -We currently support selecting Python 2.7 as an interpreter in your workspace. Because [Python 2.7 is no longer maintained as of January 2020](https://www.python.org/doc/sunset-python-2/), we strongly suggest you to upgrade your code to Python 3 as soon as you can. You can [learn how to port your code to Python 3](https://docs.python.org/3/howto/pyporting.html) if you need help. - ## Environment variables ### Environment variable definitions file An environment variable definitions file is a simple text file containing key-value pairs in the form of `environment_variable=value`, with `#` used for comments. Multiline values aren't supported, but values can refer to any other environment variable that's already defined in the system or earlier in the file. Environment variable definitions files can be used for scenarios such as debugging and tool execution (including linters, formatters, IntelliSense, and testing tools), but aren't applied to the terminal. +> **Note**: Environment variable definitions files are not necessarily cross-platform. For instance, while Unix uses `:` as a path separator in environment variables, Windows uses `;`. There is no normalization of such operating system differences, and so you need to make sure any environment definitions file use values which are compatible with your operating system. + By default, the Python extension looks for and loads a file named `.env` in the current workspace folder, then applies those definitions. The file is identified by the default entry `"python.envFile": "${workspaceFolder}/.env"` in your user settings (see [General Python settings](/docs/python/settings-reference.md#general-python-settings)). You can change the `python.envFile` setting at any time to use a different definitions file. ->**Note**: Environment definition files are not used in all situations where environment variables are available for use. Unless Visual Studio Code documentation states otherwise, these only affect certain scenarios as per their definition. For example: The extension doesn't use environment definition files when resolving setting values. +>**Note**: Environment variable definitions files are not used in all situations where environment variables are available for use. Unless Visual Studio Code documentation states otherwise, these only affect certain scenarios as per their definition. For example, the extension doesn't use environment variable definitions files when resolving setting values. A debug configuration also contains an `envFile` property that also defaults to the `.env` file in the current workspace (see [Debugging - Set configuration options](/docs/python/debugging.md#set-configuration-options)). This property allows you to easily set variables for debugging purposes that replace variables specified in the default `.env` file. @@ -322,32 +268,10 @@ You can then set the `python.envFile` setting to `${workspaceFolder}/prod.env`, ### Use of the PYTHONPATH variable -The [PYTHONPATH](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH) environment variable specifies additional locations where the Python interpreter should look for modules. In VS Code, PYTHONPATH can be set through the terminal settings (terminal.integrated.env.*) and/or within an `.env` file. +The [PYTHONPATH](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH) environment variable specifies additional locations where the Python interpreter should look for modules. In VS Code, PYTHONPATH can be set through the terminal settings (`terminal.integrated.env.*`) and/or within an `.env` file. When the terminal settings are used, PYTHONPATH affects any tools that are run within the terminal by a user, as well as any action the extension performs for a user that is routed through the terminal such as debugging. However, in this case when the extension is performing an action that isn't routed through the terminal, such as the use of a linter or formatter, then this setting won't have an effect on module look-up. -When PYTHONPATH is set using an `.env` file, it will affect anything the extension does on your behalf and actions performed by the debugger, but it will not affect tools run in the terminal. - -If needed, you can set PYTHONPATH using both methods. - -An example of when to use PYTHONPATH would be if you have source code in a `src` folder and tests in a `tests` folder. When running tests, however, those tests can't normally access modules in `src` unless you hard-code relative paths. - -To solve this problem, you could add the path to `src` to PYTHONPATH by creating an `.env` file within your VS Code workspace. - -```bat -PYTHONPATH=src -``` - -Then set `python.envFile` in your `settings.json` file to point to the `.env` file you just created. For example, if the `.env` file was in your workspace root, your `settings.json` would be set as shown: - -```json -"python.envFile": "${workspaceFolder}/.env" -``` - -The value of PYTHONPATH can contain multiple locations separated by `os.pathsep`: a semicolon (`;`) on Windows and a colon (`:`) on Linux/macOS. Invalid paths are ignored. If you find that your value for PYTHONPATH isn't working as expected, make sure that you're using the correct separator between locations for the operating system. For example, using a colon to separate locations on Windows, or using a semicolon to separate locations on Linux/macOS results in an invalid value for PYTHONPATH, which is ignored. - -> **Note**: PYTHONPATH does **not** specify a path to a Python interpreter itself. For additional information about PYTHONPATH, read the [PYTHONPATH documentation](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH). - ## Next steps - [Editing code](/docs/python/editing.md) - Learn about autocomplete, IntelliSense, formatting, and refactoring for Python. From e319c887532e7fa492de29a1827dfe8cc731f29a Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 20 Jan 2023 09:48:09 -0800 Subject: [PATCH 2/3] Address review feedback --- docs/python/environments.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/python/environments.md b/docs/python/environments.md index 91e61d36c9..bb5835fc96 100644 --- a/docs/python/environments.md +++ b/docs/python/environments.md @@ -20,15 +20,15 @@ This article discusses the helpful Python environments features available in Vis By default, any Python interpreter installed runs in its own **global environment**. For example, if you just run `python`, `python3`, or `py` at a new terminal (depending on how you installed Python), you're running in that interpreter's global environment. Any packages that you install or uninstall affect the global environment and all programs that you run within it. -Do note that if you install packages into your global environment, though, in time it will become crowded with disparate packages and make it difficult to properly test an application. You typically want to create an environment for each workspace. +Do note that if you install packages into your global environment, though, in time it will become crowded with potentially unrelated or unexpected packages and make it difficult to properly test an application. You typically want to create an environment for each workspace. ### Local environments -There are two types of environments that you can create for your workspace: *virtual* and *conda* environments. Both types of environment provide a way to create an environment to install packages into. This lets you isolate what packages you install for your workspace so that they don't interfere with your needs in another workspace. +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 environments -A [**virtual environment**](https://docs.python.org/3/glossary.html#term-virtual-environment) is 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. +A [**virtual environment**](https://docs.python.org/3/glossary.html#term-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. > **Note**: While it's possible to open a virtual environment folder as a workspace, doing so is not recommended and might cause issues with using the Python extension. From ae506b1d5d12803cba3ba1600296230bd4660dec Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 20 Jan 2023 09:51:02 -0800 Subject: [PATCH 3/3] Update `DateApproved` --- docs/python/environments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/python/environments.md b/docs/python/environments.md index bb5835fc96..52da40b402 100644 --- a/docs/python/environments.md +++ b/docs/python/environments.md @@ -4,7 +4,7 @@ Area: python TOCTitle: Environments ContentId: 8fe4ca8b-fc70-4216-86c7-2c11b6c14cc6 PageTitle: Using Python Environments in Visual Studio Code -DateApproved: 11/3/2022 +DateApproved: 01/20/2023 MetaDescription: Configuring Python Environments in Visual Studio Code MetaSocialImage: images/tutorial/social.png ---