-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fixing "deactivate" command for virtual environments
"deactivate" not working by default is a limitation of our new approach to activate terminals. To fix this add the following script to any of the init scripts for the shell you're using:
Bash
- Add one of the following to
~/.bashrc
file. Runcode ~/.bashrc
in bash to open the file in VS Code:-
Download
deactivate
script and add the following:source <path_to_dir>/deactivate
-
Or add contents of
deactivate
directly.
-
Powershell
- Add one of the following to your PowerShell profile. Run
code $Profile
in pwsh to open the file in VS Code:-
Download
deactivate.ps1
script and add the following:& "<path_to_dir>/deactivate.ps1"
-
Or add contents of
deactivate.ps1
directly.
-
Zsh
- Add one of the following to
~/.zshrc
file. Runcode ~/.zshrc
in bash to open the file in VS Code:-
Download
deactivate
script and add the following:source <path_to_dir>/deactivate
-
Or add contents of
deactivate
directly.
-
Fish
- Add one of the following to your
config.fish
. Runcode $__fish_config_dir/config.fish
in fish to open the file in VS Code:-
Download
deactivate.fish
script and add the following:source <path_to_dir>/deactivate.fish
-
Or add contents of
deactivate.fish
directly.
-
Csh
-Add one of the following to your ~/.cshrc
. Run code ~/.cshrc
in fish to open the file in VS Code:
-
Download
deactivate.csh
script and add the following:source <path_to_dir>/deactivate.csh
-
Or add contents of
deactivate.csh
directly.
Other shells
- Use default script for the OS:
- If on Windows, use the script under
Powershell
category. - Otherwise, use the script under
Bash
category.
- If on Windows, use the script under
- Add the script at the end of corresponding initialization script for your shell.
In the new approach, we do not run <venv>/<bin>/activate
script which traditionally registers the deactivate
shell hook. Hence we need to add it manually to shell initialization script (~/.bashrc
for example) which is executed automatically when a terminal starts.
Turn off auto-activation: Set "python.terminal.activateEnvironment": false
and reopen the shells.