-
Notifications
You must be signed in to change notification settings - Fork 36
Terminal Auto‐Activation Explained
Setting: Terminal Auto-Activation Type
Id: python-envs.terminal.autoActivationType
Purpose: Controls how the Python Environments extension activates the selected Python environment when a new terminal is created in VS Code.
When auto-activation is enabled, the extension ensures python, pip, and related tools resolve to the interpreter in your chosen environment without requiring you to run activation commands manually.
-
Command (default at the moment)
Runs the environment’s activation command in the terminal right after it opens. -
Command Shell Startup (Will be the default once environment extension is rolled out fully to all of Python extension users)
Activates your terminal without needing to send visual activation command in terminal. Meaning, terminal would be activated on creation. This is the recommended activation type to get Copilot terminal activated properly.
If you would like to revert all of the changes Python environment extension has made to your profile scripts, please run command python-envs.terminal.revertStartupScriptChanges
-
Off
Disables automatic activation entirely.
- When you open a new terminal in VS Code, the extension runs the activation command in that terminal session.
- The exact activation command depends on:
- Your shell type (e.g., Bash, Zsh, PowerShell, Command Prompt)
- Your OS type (Windows, macOS, Linux)
- Your environment type (e.g., venv, Conda, Pipenv)
- After the command runs,
pythonresolves to your selected environment.
- Open a new terminal in VS Code — you should see the activation command executed automatically at the top.
- Determine the correct activation command by activating your environment manually outside of VS Code (using the correct command for your shell, OS, and environment type).
- Compare:
- The command VS Code executed
- The command that works outside VS Code
- If they differ:
- Report the mismatch, or
- Check additional settings that might influence the environment path (e.g., default interpreter path settings, environment variables).
- The extension contributes environment variables which contains activate command specific to your environment and platform.
- Implementation differs by shell:
-
Bash, Zsh, Fish, PowerShell → When shell integration is enabled and properly injected, we activate by running the activate hooks from VS Code's shell integration script. In remote scenarios or for shells that do not support terminal shell integration, we prompt user for the modification of profile scripts or
autorunentry in order to make this auto-activation to be effective and your prompt to be changed accordingly on terminal creation. -
Command Prompt (
cmd.exe) → Sets a Windows Registryautorunentry that runs a.batscript on shell start.
-
- Injected scripts will include comment markers like:
# >>> vscode python # version: 0.1.0 ... # <<< vscode python
- Once set, any terminal of that type opened in VS Code will have the environment active immediately.
- If at any time you want to remove these changes, run
Python Envs: Revert Shell Startup Script Changesfrom the Command Palette.
For full details on how shell startup activation is implemented (including script examples for each shell type), see the (Maybe outdated, TODO: @anthonykim1 to update) Shell Startup Activation section of the README.
- Recommended for Copilot when they run commands in a new terminal and need the environment to be active before the first command executes.
Command Prompt
- Open Registry Editor and navigate to:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor - Look for the
autorunvalue — it should point to a.batfile used for activation. - If missing, open a cmd terminal in VS Code, set the auto-activation type to Command Shell Startup, and reload the window to trigger injection.
Information to include in a bug report
- Shell type (Bash, Zsh, PowerShell, Command Prompt, Fish)
- OS (Windows/macOS/Linux)
- Environment type (venv, Conda, Pipenv, etc.)
- Auto-Activation Type setting value (Command / Command Shell Startup / Off)
- Expected behavior
- Actual behavior
-
If Command mode:
- Activation command injected by VS Code
- Activation command that works outside VS Code
-
If Command Shell Startup mode:
- Is
terminal.integrated.shellIntegration.enabledset to true? - What is the quality of your shell integration? This should be visible when you hover over terminal tab, it should be either Rich, Basic, or None.
- Are you on remote scenario, if so, what is your setup?
- For Bash/Zsh/Fish/PowerShell: Is the snippet with
# >>> vscode pythonpresent in the profile file?- Profile file path
- For Command Prompt: Is
autorunregistry value present?- Path in
autorunvalue
- Path in
- Is
- Whether the issue happens in only one shell or multiple shells
- Whether it reproduces after Reload Window and opening a fresh terminal or restarting VS Code?