Type deactivate in the integrated terminal and press Enter. The (venv) prefix disappears from the prompt, and the shell goes back to whatever Python it was using before.
That only applies to the one shell session you typed it in. VS Code’s Python environments documentation (2026) says the default mode runs the activation command after each new terminal opens, so the next terminal you open gets the venv back.
The interpreter VS Code has selected is a separate setting, and deactivate never touches it.
How to Exit a Venv in the VSCode Terminal

In the integrated terminal, deactivate followed by Enter is all it takes. The prompt loses its (venv) prefix and the shell returns to the Python it used before activation.
Activation puts the environment’s bin or Scripts folder at the front of PATH, and deactivate reverses that. Python’s documentation describes the mechanism as a platform-specific implementation detail, typically a script or shell function, which is also why the command only exists inside a shell where the environment is active.
- Open the terminal panel with Ctrl+
on Windows and Linux or Control+on macOS, or use View > Terminal. - Look for (venv) at the start of the prompt. It tells you this shell session has the environment active.
- Type deactivate and press Enter.
- Check that the prefix is gone and the prompt shows the plain folder path again.
If the panel won’t open, there’s a guide to opening the terminal in VSCode that goes through the menu and shortcut routes.
Windows: PowerShell and Command Prompt
PowerShell activates the environment through Scripts\Activate.ps1, and Command Prompt through Scripts\activate.bat.
Neither changes how you leave. It’s deactivate in both.
macOS, Linux and Git Bash
On bash and zsh, activation runs source followed by the bin/activate path, and typing deactivate exits the same way.
Git Bash on Windows is the odd one out. It sources the bash-style activate file inside the Scripts folder, not bin, and a vscode-python debugger issue log shows the extension running exactly that kind of Scripts/activate call.
To get back into the environment later, run the same activate script again. There’s a guide to activating a venv in VSCode if you want the details.
How Can You Check That the Venv Is Really Off?
Run where python on Windows or which python on macOS and Linux. If the first path is outside the .venv or venv folder, the environment is off. Where python lists every match in PATH order, so the first line is the one that actually runs.
You can also ask Python directly. Inside a venv, sys.prefix and sys.base_prefix differ, so python -c “import sys; print(sys.prefix != sys.base_prefix)” prints False when no venv is in use.
echo $VIRTUAL_ENV in bash or zsh, or echo $env:VIRTUAL_ENV in PowerShell, should come back empty. And pip –version prints the path of the pip in use, so a site-packages path inside .venv means the venv is still in play.
The prompt prefix is the weakest signal, and I wouldn’t trust it on its own. The Python extension’s wiki says it now activates environments through environment variables, so the usual indicator may not update while the environment is still active.
Hovering over the terminal tab shows which environment is activated, and choosing “Show environment contributions” lists the variables the extension applied.
Python’s own documentation adds a second warning. Activation is optional, so VIRTUAL_ENV cannot be relied on to tell you whether a venv is in use.
So the prefix and VIRTUAL_ENV only show that an activation script ran. The interpreter path and sys.prefix show which Python actually executes, and those are the two worth going by.
How Do You Switch VSCode From a Venv to the System Interpreter?
Open the Command Palette (Ctrl+Shift+P), run Python: Select Interpreter, and pick the global Python from the list. The Python version in the status bar opens the same picker.
For a fuller walkthrough of the picker, see this guide to changing the Python interpreter in VSCode.
What the selected interpreter controls
The Run buttons use whatever environment is selected, and Pylance resolves imports and completions against the same choice. The debugger uses it by default too, though a python key in launch.json overrides that.
The terminal is a separate layer, so running deactivate in a shell does not change the interpreter VSCode has selected.
Two switches, in other words, and neither knows about the other.
Why VSCode picks the venv again
When no interpreter has been chosen, the extension checks workspace-local environments named .venv and venv first, then falls back to global interpreters. Project settings, along with a default environment manager or default interpreter path, get checked before that automatic discovery.
A project with a .venv folder therefore lands back in that venv until a global interpreter is selected explicitly. Make the explicit choice and auto-selection stops deciding for you.
How Do You Stop VSCode From Activating the Venv in Every New Terminal?
Turn auto-activation off in settings.json. Set python-envs.terminal.autoActivationType to off, or the legacy python.terminal.activateEnvironment setting to false, then kill the open terminal and start a new one.
The current setting and the legacy one
VS Code’s Python environments documentation (2026) gives python-envs.terminal.autoActivationType the values below.
| Value | Behavior |
|---|---|
| shellStartup | Activates through shell startup scripts, so the environment is active when the terminal opens |
| command (default) | Runs the activation command visibly after the terminal opens |
| off | No automatic activation |
The same page says shellStartup will become the default in a future release, and it gives no version number. The older python.terminal.activateEnvironment setting still works, but the new one takes precedence when both are set.
The vscode-python issue tracker documents the older setting with the value false. There’s also python.terminal.activateEnvInCurrentTerminal, which covers terminals that are already open.
User scope or workspace scope
User settings apply everywhere, while the settings.json inside a workspace’s .vscode folder applies to that project only.
Use user scope if you never want a terminal activating anything on its own. Workspace scope makes more sense when one project’s venv should stay manual and every other project keeps auto-activation.
The file opens from the Command Palette, and this guide to opening settings.json in VSCode shows the other routes.
Applying the change
The documentation says terminals need a restart after autoActivationType changes.
- Kill the terminal with the trash can icon on its tab, or run Terminal: Kill the Active Terminal Instance.
- Open a fresh one with Ctrl+Shift+` or the + icon in the panel.
- Run where python or which python to confirm the path sits outside the venv.
If you picked shellStartup earlier, Python Envs: Revert Shell Startup Script Changes undoes what it wrote.
Settings only decide what future terminals do. A terminal that opened with the venv already active still needs deactivate.
Which Exit Method Should You Use?
The methods differ mostly in how far they reach. deactivate stays inside one shell, while Select Interpreter works on the editor side and the auto-activation setting decides how every later terminal starts.
| Method | Scope | Lasts until | Reach for it when |
|---|---|---|---|
| deactivate | One shell session | The terminal closes or the venv is activated again | One task needs the global Python |
| Kill the terminal | One terminal instance | The next terminal opens and the activation command runs | You want a clean shell and auto-activation is off |
| Select Interpreter | Editor, Pylance, debugger | You pick another interpreter | Imports resolve against the wrong environment |
| Auto-activation off | Every new terminal | The setting changes | Terminals should always start clean |
Killing the terminal looks like an exit and is not one while auto-activation is on. In the default command mode the activation command runs after each new terminal opens, so the venv comes back with the next terminal.
For a one-off task outside the venv, run deactivate, finish the task, and activate again later. If the prefix keeps returning in every new terminal, change the auto-activation setting, because the shell isn’t the problem. And when the editor flags missing imports, the selected interpreter is the cause, so switch that instead.
Most guides stop at deactivate. It is the cheapest fix and the one least likely to stick.
Why Does Deactivate Fail in VSCode, and How Do You Fix It?
Nearly every failure comes back to the newer terminal activation approach. It does not run the venv’s activate script, which is what normally registers the deactivate function, and a Microsoft maintainer suspects a bug in the environment-variable path that stops it saving the old state needed for restoration.
The command is not recognized or not on PATH
Microsoft’s vscode-python wiki treats the missing command as a limitation of that newer approach. The documented fix is a deactivate hook script, downloaded to a folder such as ~/.vscode-python and sourced from your shell’s init file.
| Shell | Script | Init file |
|---|---|---|
| Bash | deactivate | ~/.bashrc |
| Zsh | deactivate | ~/.zshrc |
| PowerShell | deactivate.ps1 | PowerShell profile |
| Fish | deactivate.fish | config.fish |
| csh | deactivate.csh | ~/.cshrc |
Restart the shell after the edit, because reloading VS Code does not apply it. The wiki was last edited on October 24, 2023, so it’s worth a skeptical read.
Its alternative is turning off auto-activation with python.terminal.activateEnvironment set to false. That name predates python-envs.terminal.autoActivationType, so use the current setting where your build offers it.
PATH stays modified after deactivate on Windows
This one is irritating in a specific way. After the extension auto-activated a venv in a cmd terminal, deactivate restored the prompt and removed VIRTUAL_ENV but left the venv’s Scripts folder on PATH, so where python still found the venv’s interpreter (Python extension 2024.16.0, VS Code 1.94.0, vscode-python issue 24238, October 2024).
According to the maintainer, type 1 activation runs activate when the terminal is created and sets up deactivate correctly. Type 2 updates environment variables in the background and does not appear to save the old state, which the maintainer said might be a bug.
The maintainer’s workaround was opting out of the pythonTerminalEnvVarActivation experiment, which switches the extension to type 1 activation. A commenter confirmed it fixed the problem, and the issue was closed on the grounds that type 1 activation addresses it.
The sources disagree a little here. Python’s documentation presents deactivate as the way out of an activated environment, and under a normal activation it is. The issue tracker documents a case where it clears the prompt prefix and leaves the PATH change behind.
Another extension interferes with activation
Issue 24643 reported a (.venv) prefix with deactivate missing from PATH on VS Code 1.96.0 with Python extension 2024.22.0 and GitHub Copilot 1.249.0. Disabling Copilot and opening a new terminal made activation work, while rolling Copilot back three releases did not.
There’s a guide to disabling GitHub Copilot in VSCode if you want to run that first test.
The maintainer’s workaround is adding “python.experiments.optOutFrom”: [“pythonTerminalEnvVarActivation”] to user settings, then reloading the window. The reporter confirmed it made the terminal activate the venv as expected.
Both issues point to the same experiment. The 2026 VS Code documentation covers autoActivationType instead, so treat the opt-out as a fix reported against 2024 builds.
The venv returns after a restart and deactivate is rejected
Closing VSCode with a venv still active can leave the next session half-activated.
One developer report (Qiita, January 2025) says the restored terminal started the venv without a recorded state to return to, so deactivate was refused. Setting terminal.integrated.shellIntegration.enabled to false fixed it for that reporter, as did resetting the VS Code user settings folder.
It is a single report, not a vendor confirmation. Kill the terminal and open a new one before touching any settings folder.
PowerShell blocks the activate script
The error says running scripts is disabled on this system, and no (venv) prefix appears. Windows PowerShell 5.1 on Windows 10 and Windows 11 defaults to the Restricted execution policy, which blocks all scripts, including ones you write on the local computer. PowerShell 7 on Windows defaults to RemoteSigned instead, so the error is most common in Windows PowerShell 5.1.
Python’s documentation gives Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser as the fix. RemoteSigned lets scripts run but requires a trusted signature on scripts downloaded from the internet.
A blocked Activate.ps1 never defines the deactivate function, which is why the failure shows up as an unrecognized command.
Every failure above has the same root. The activate script didn’t run cleanly in that terminal, so deactivate is missing or only half there.
What Stays After You Exit a Venv?
Everything stays. Exiting ends the activation and nothing else, so the environment folder is still on disk with its packages and pyvenv.cfg, and activating again brings the same environment back.
The folder is conventionally named .venv or venv and sits inside the project directory. Installed packages live in the environment’s own site-packages, apart from the system Python. The pyvenv.cfg file marks the interpreter as part of a virtual environment, and a home key in it points to the base installation.
PEP 405 (Final, targeting Python 3.3) defines these environments as lightweight, with their own site directories, and added the venv module to the standard library.
Rebuild it instead of repairing it
Python’s documentation calls environments disposable and not movable, because the shebang lines in installed scripts hold absolute paths.
The documented recovery is to recreate the environment and run pip install -r requirements.txt with the new environment’s pip. That is why a requirements.txt file matters more than the folder itself.
Keeping it out of version control
Since Python 3.13, venv creates a .gitignore by default, and the –without-scm-ignore-files option skips it.
For older environments, the documentation says an environment should not be committed to source control, so add the folder to .gitignore by hand.
Deleting the venv for good
Deactivate first, then remove the folder.
In the Explorer, right-click the .venv folder and delete it. On macOS and Linux, rm -r .venv does the same job, and in PowerShell it’s Remove-Item -Recurse -Force .venv.
Pick a new interpreter afterward so the status bar does not point at a folder that no longer exists. There’s a guide to deleting a venv with more detail on the cleanup.
FAQ About Exiting a Venv in VSCode
Is the exit command different for virtualenv?
No. virtualenv’s documentation lists deactivate as the way to exit the environment, and its activate script provisions that command, just as venv’s does.
How do you exit a conda environment in VSCode?
Run conda deactivate in the terminal. Conda removes that environment’s path from your command path.
Skip it in the base environment. The conda documentation warns that doing so can cost you the ability to run conda at all, and opening a new shell fixes that.
Does typing exit work instead of deactivate?
Yes for Pipenv and Poetry shells, no for a plain venv. Pipenv’s documentation says to type exit or press Ctrl+D to leave pipenv shell, and a Poetry shell works the same way.
Both tools open a subshell, so exit closes it. In a plain venv, exit closes the terminal’s shell and deactivates nothing.
Do you have to deactivate one venv before activating another?
No. The standard activation scripts do not nest, so activating a second venv replaces the first.
One deactivate afterward returns the shell to a state with no active environment.
Making Venv Activation a Manual Choice in VSCode
Exiting a venv in VSCode stops being a recurring chore once auto-activation is off at workspace scope. Terminals then open clean, and the venv starts only when a task calls for it.
The setting goes first because it governs every terminal opened afterward. After that, select the interpreter once, on purpose, and activate by hand wherever a terminal needs the venv.
Manual activation does cost you some discipline. A forgotten activation sends pip install to the global interpreter, so run where python or which python before installing anything.
This order was verified on November 21, 2026 against VS Code’s Python environments documentation. A new default for python-envs.terminal.autoActivationType would change it.
With the terminal under control, the next job is running Python in VSCode against the interpreter you selected.
- How to Choose a Digital Transformation Consulting Partner - November 30, 2026
- Is Notepad++ Safe? Official Download, Updates, CVEs - November 29, 2026
- How to Evaluate an AI Code Reviewer on Your Own Pull Requests - November 29, 2026



