Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Visual Studio Code from activating the Python virtual environment

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?

like image 509
Lars Blumberg Avatar asked Feb 21 '19 08:02

Lars Blumberg


People also ask

How do I disable VENV in Vscode?

Just type "workon" with no arguments and hit enter. The command to leave is "deactivate", as answered below.

How do I stop a Python virtual environment?

You can exit from the virtualenv using exit command, or by pressing Ctrl+d.

How do I stop the Python code from running in Visual Studio code?

To stop running a program before it's complete, use the red square stop button on the debug toolbar (Shift+F5), or use the Run > Stop debugging menu command. For full details, see Debugging configurations, which includes notes on how to use a specific Python interpreter for debugging.

How to activate or deactivate the Python virtual environment?

There is a file with the name of ‘activate.bat’ inside of the folder. That file is a file which is very useful to activate the python virtual environment. On the other hand, there is also another file with the name of ‘deactivate.bat’. It is actually a file for deactivating the python virtual environment.

How to manage environments for Python code in Visual Studio Code?

You can't manage environments for Python code that is opened only as a folder using the File > Open > Folder command. Instead, Create a Python project from existing code to enjoy the environment features of Visual Studio.

How do I activate the Python extension in Visual Studio Code?

Once you have a version of Python installed, activate it using the Python: Select Interpreter command. If VS Code doesn't automatically locate the interpreter you're looking for, refer to Environments - Manually specify an interpreter. You configure the Python extension through settings.

How do I create a Python virtual environment in VS Code?

Note: If you're using a version of the Python extension prior to 2018.10, and you create a virtual environment in a VS Code terminal, you must run the Reload Window command from the Command Palette and then use Python: Select Interpreter to activate the environment.


1 Answers

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).

like image 127
Brett Cannon Avatar answered Oct 11 '22 00:10

Brett Cannon