Skip to content

Commit 778fa93

Browse files
authored
Merge pull request #2470 from Microsoft/python-feedback
Small feedback edits
2 parents b450938 + b08b1d0 commit 778fa93

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

docs/python/environments.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To select a specific environment, use the **Python: Select Interpreter** command
2424

2525
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.
2626

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:
2828

2929
![List of interpreters](images/environments/interpreters-list.png)
3030

@@ -34,7 +34,7 @@ Selecting an interpreter from the list adds an entry for `python.pythonPath` wit
3434

3535
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.
3636

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).
3838
3939
> **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).
4040
@@ -138,47 +138,46 @@ For more information on the conda command line, see [Conda environments](https:/
138138
139139
### Manually specify an interpreter
140140

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.)
142142

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**.
144144

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 ):
146148

147149
For example:
148150

149151
- Windows:
150152

151153
```json
152-
"python.pythonPath": "c:/python36/python.exe"
154+
"python.pythonPath": "c:/python36/python.exe",
153155
```
154156

155157
- macOS/Linux:
156158

157159
```json
158-
"python.pythonPath": "/home/python36/python"
160+
"python.pythonPath": "/home/python36/python",
159161
```
160162

161163
1. You can also use `python.pythonPath` to point to a virtual environment, for example:
162164

163165
Windows:
166+
164167
```json
165-
{
166-
"python.pythonPath": "c:/dev/ala/venv/Scripts/python.exe"
167-
}
168+
"python.pythonPath": "c:/dev/ala/venv/Scripts/python.exe",
168169
```
169170

170171
macOS/Linux:
172+
171173
```json
172-
{
173-
"python.pythonPath": "/home/abc/dev/ala/venv/bin/python"
174-
}
174+
"python.pythonPath": "/home/abc/dev/ala/venv/bin/python",
175+
```
175176

176177
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:
177178

178179
```json
179-
{
180-
"python.pythonPath": "${env:PYTHON_INSTALL_LOC}"
181-
}
180+
"python.pythonPath": "${env:PYTHON_INSTALL_LOC}",
182181
```
183182

184183
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:
238237
- 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.
239238
- 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`.
240239
- 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).
242241
- You can use only simple substitution; nesting such as `${_${OTHERVAR}_EX}` is not supported.
243242
- Entries with unsupported syntax are left as-is.
244243

0 commit comments

Comments
 (0)