|
| 1 | +--- |
| 2 | +title: "Discovering Python Installations" |
| 3 | +--- |
| 4 | + |
| 5 | +This guide explains how Python installations are discovered and managed in Positron. |
| 6 | + |
| 7 | +## Python installation discovery |
| 8 | + |
| 9 | +Positron uses multiple strategies to discover Python interpreters and virtual environments across your system. |
| 10 | +The discovery process includes both global Python installations and various virtual environment managers. |
| 11 | + |
| 12 | +### Supported environment managers |
| 13 | + |
| 14 | +Positron supports the following Python environment managers: |
| 15 | + |
| 16 | +* **venv**: Standard library virtual environments created with `python -m venv` |
| 17 | +* **uv**: Virtual environments and Python installations managed by `uv` |
| 18 | +* **pyenv**: Python installations managed by `pyenv`, including virtual environments |
| 19 | +* **conda**: Conda environments created with `conda create` or `mamba create` |
| 20 | + |
| 21 | +Other tools may also be compatible, although they are not officially supported at this time. |
| 22 | + |
| 23 | +### Discovery locations |
| 24 | + |
| 25 | +Positron searches for Python interpreters in the following locations: |
| 26 | + |
| 27 | +**Virtual environments** |
| 28 | + |
| 29 | +* `.venv/` and `.conda/` folders in your [workspace](https://code.visualstudio.com/docs/editing/workspaces/workspaces#_singlefolder-workspaces) directory |
| 30 | +* Tool-managed project-specific installations in locations like `~/.local/share/virtualenvs` or where `conda` stores envs |
| 31 | + |
| 32 | +**Global Python installations** |
| 33 | + |
| 34 | +* System Python installations in standard locations like the user's `PATH` |
| 35 | +* `/opt/python` |
| 36 | +* Tool-managed installation locations like `~/.pyenv` or ` ~/.local/share/uv/python/` |
| 37 | + |
| 38 | +Note that using a system Python installation in a new session can lead to problems (see the official [guidance](https://packaging.python.org/en/latest/specifications/externally-managed-environments/) about this). |
| 39 | +For that reason, we recommend using virtual environments. |
| 40 | + |
| 41 | +**Custom locations** |
| 42 | + |
| 43 | +* Interpreters listed in the [`python.interpreters.[include,exclude,override]` settings](positron://settings/python.interpreters.include) (see [Related Settings](#related-settings) below for details) |
| 44 | + |
| 45 | +## Environment creation and discovery |
| 46 | + |
| 47 | +### Creating new environments |
| 48 | + |
| 49 | +You can create new Python environments directly from Positron using the _Python: Create Environment_ command: |
| 50 | + |
| 51 | +1. Open the Command Palette (<kbd>Cmd/Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>) |
| 52 | +2. Select _Python: Create Environment_ |
| 53 | +3. Choose from available environment providers: |
| 54 | + - **uv**: Creates a uv-managed virtual environment (if uv is available) |
| 55 | + - **venv**: Creates a standard virtual environment using `python -m venv` |
| 56 | + - **conda**: Creates a conda environment (if conda is available) |
| 57 | + |
| 58 | +The environment will be created in your workspace and automatically discovered. |
| 59 | + |
| 60 | +You can also use the **New Folder From Template** feature to create a new Python project, and set up an environment as part of the project. |
| 61 | + |
| 62 | +### Discovering existing environments |
| 63 | + |
| 64 | +Positron automatically discovers environments when: |
| 65 | + |
| 66 | +- You open Positron |
| 67 | +- You open a new workspace folder |
| 68 | +- Certain file system changes are detected in watched directories |
| 69 | +- You manually refresh using the _Interpreter: Discover All Interpreters_ command |
| 70 | + |
| 71 | +The discovery process runs in the background and updates the interpreter list as new environments are found. |
| 72 | + |
| 73 | +## Discovery process details |
| 74 | + |
| 75 | +### Unsupported Python versions |
| 76 | + |
| 77 | +Positron only supports Python minor versions 3.9 through 3.13, which are the [currently supported versions](https://devguide.python.org/versions/). |
| 78 | +Other versions may be discovered, but you may run into issues using them. |
| 79 | + |
| 80 | +### Locator type |
| 81 | + |
| 82 | +Positron can use two different discovery mechanisms: |
| 83 | + |
| 84 | +* **JavaScript locator** (default): Pure TypeScript implementation for more comprehensive discovery |
| 85 | +* **Native locator** (experimental): Uses a native binary for faster discovery |
| 86 | + |
| 87 | +You can control this with the [`python.locator` setting](positron://settings/python.locator) (`"js"` or `"native"`). |
| 88 | +Keep in mind that the `native` locator is experimental and may not work completely as intended. |
| 89 | + |
| 90 | +## Troubleshooting |
| 91 | + |
| 92 | +### Environment not appearing |
| 93 | + |
| 94 | +If the above settings are configured correctly, and the Python version is supported, and _Interpreter: Discover All Interpreters_ or a restart of Positron is not helping, you can check logs. See more in the [troubleshooting guide](troubleshooting.qmd). |
| 95 | + |
| 96 | +For the `js` (default) locator, the discovery process is logged in the Python Language Pack channel of the Output panel. |
| 97 | + |
| 98 | +For the `native` locator, it is instead logged in the Python Locator channel. |
| 99 | + |
| 100 | +## Related settings |
| 101 | + |
| 102 | +Key settings that control Python environment discovery: |
| 103 | + |
| 104 | +### Discovery location settings |
| 105 | +* [`python.interpreters.include`](positron://settings/python.interpreters.include): Specific interpreter paths to include |
| 106 | +* [`python.interpreters.exclude`](positron://settings/python.interpreters.exclude): Interpreter paths to exclude from discovery |
| 107 | +* [`python.interpreters.override`](positron://settings/python.interpreters.override): Override the above two settings so only these are shown |
| 108 | + |
| 109 | +### Environment providers |
| 110 | +* [`python.environmentProviders.enable`](positron://settings/python.environmentProviders.enable): Enable/disable specific environment providers for environment creation (`Venv`, `Conda`, `uv`) |
| 111 | + |
| 112 | +### Discovery behavior |
| 113 | +* [`python.locator`](positron://settings/python.locator): Choose between "native" or "js" discovery methods |
| 114 | +* [`python.defaultInterpreterPath`](positron://settings/python.defaultInterpreterPath): Default Python interpreter path (used only the first time when no other interpreter takes precedence) |
| 115 | + |
| 116 | +## Related commands |
| 117 | + |
| 118 | +* _Interpreter: Discover All Interpreters_: Find new interpreters |
| 119 | +* _Interpreter: Select Interpreter Session_: Select an interpreter for a session |
| 120 | +* _Python: Create Environment_: Create a new virtual environment |
0 commit comments