21

With a Python project opened, whenever I open the integrated terminal in Visual Studio Code it's automatically activating the virtual environment. I'm sure that's done by VS Code because I can find this command in the bash history of that terminal:

source <project-directory>/venv/bin/activate

I don't want the virtual environment to be activated. How can we prevent VS Code from doing that?

Lars Blumberg
  • 19,326
  • 11
  • 90
  • 127

2 Answers2

43

Add "python.terminal.activateEnvironment": false to your settings (globally to your user settings if you never want it, otherwise your settings.json file which is found in .vscode directory; this folder is found in your workspace directory if this is a per-workspace thing for you; docs).

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40
1

If you open the vscode terminal first and then select python interpreter, then it won't activate the python environment. This answer works in vscode 1.44.0 with pyhton 3.8.1. I haven't tested with other versions. However, if you have any files or workspace open you need to close that first to close the python interpreter. You don't need to make any changes in settings.