You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/python/environments.md
+16-17Lines changed: 16 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ To select a specific environment, use the **Python: Select Interpreter** command
24
24
25
25
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.
26
26
27
-
The **Python: Select Interpreter** command displays a list of available global environments, conda environments, and virtual environments. (See [Where the extension looks for environments](#where-the-extension-looks-for-environments) in a later 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:
27
+
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:
28
28
29
29

30
30
@@ -34,7 +34,7 @@ Selecting an interpreter from the list adds an entry for `python.pythonPath` wit
34
34
35
35
The Python extension uses the selected environment for running Python code (using the **Python: Run Python File in Terminal** command), providing language services (auto-complete, syntax checking, linting, formatting, etc.) when you have a `.py` file open in the editor, and opening a terminal with the **Terminal: Create New Integrated Terminal** command. In the latter case, VS Code automatically activated the selected environment.
36
36
37
-
> **Tip**: To prevent automatic activation of a selected environment, add `"python.terminal.activateEnvironment": false` to your `settings.json` file.
37
+
> **Tip**: To prevent automatic activation of a selected environment, add `"python.terminal.activateEnvironment": false` to your `settings.json` file (it can be placed anywhere as a sibling to the existing settings).
38
38
39
39
> **Note**: By default, VS Code uses the interpreter identified by `python:pythonPath` setting when debugging code. You can override this behavior by specifying a different path in the `pythonPath` property of a debug configuration. See [Choose a debugging environment](#choose-a-debugging-environment).
40
40
@@ -138,47 +138,46 @@ For more information on the conda command line, see [Conda environments](https:/
138
138
139
139
### Manually specify an interpreter
140
140
141
-
If VS Code does not automatically locate an interpreter you want to use, you can set the path to it manually in your Workspace Settings `settings.json` file:
141
+
If VS Code does not automatically locate an interpreter you want to use, you can set the path to it manually in your Workspace Settings `settings.json` file. With any of the entries that follow, you can just add the line as a sibling to other existing settings.)
142
142
143
-
1. Select the **File** (**Code** on macOS) > **Preferences** > **Settings** menu command (`kb(workbench.action.openSettings)`) to open your [Settings](/docs/getstarted/settings.md), select **Workspace**, and then do any of the following:
143
+
First, select the **File** (**Code** on macOS) > **Preferences** > **Settings** menu command (`kb(workbench.action.openSettings)`) to open your [Settings](/docs/getstarted/settings.md), select **Workspace**.
144
144
145
-
1. Create or modify an entry for `python.pythonPath` with the full path to the Python executable:
145
+
Then do any of the following steps:
146
+
147
+
1. Create or modify an entry for `python.pythonPath` with the full path to the Python executable (if you edit `settings.json` directly, add the line below as the setting ):
146
148
147
149
For example:
148
150
149
151
- Windows:
150
152
151
153
```json
152
-
"python.pythonPath": "c:/python36/python.exe"
154
+
"python.pythonPath": "c:/python36/python.exe",
153
155
```
154
156
155
157
- macOS/Linux:
156
158
157
159
```json
158
-
"python.pythonPath": "/home/python36/python"
160
+
"python.pythonPath": "/home/python36/python",
159
161
```
160
162
161
163
1. You can also use `python.pythonPath` to point to a virtual environment, for example:
1. You can 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:
177
178
178
179
```json
179
-
{
180
-
"python.pythonPath": "${env:PYTHON_INSTALL_LOC}"
181
-
}
180
+
"python.pythonPath": "${env:PYTHON_INSTALL_LOC}",
182
181
```
183
182
184
183
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.
@@ -238,7 +237,7 @@ Within this syntax, the following rules apply:
238
237
- Variables are processed in the order they appear in the `.env` file, so you can use any variable that's defined earlier in the file.
239
238
- Single or double quotes don't affect substituted value and are included in the defined value. For example, if the value of `VAR1` is `abcedfg`, then `VAR2='${OTHERVAR}'` assigns the value `'abcedfg'` to `VAR2`.
240
239
- The `$` character can be escaped with a backslash, as in `\$`.
241
-
- You can use recursive substitution, such as `PYTHONPATH=$PROJ_DIR:${PYTHONPATH}`.
240
+
- You can use recursive substitution, such as `PYTHONPATH=${PROJ_DIR}:${PYTHONPATH}` (where `PROJ_DIR` is any other environment variable).
242
241
- You can use only simple substitution; nesting such as `${_${OTHERVAR}_EX}` is not supported.
0 commit comments