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?
Just type "workon" with no arguments and hit enter. The command to leave is "deactivate", as answered below.
You can exit from the virtualenv using exit command, or by pressing Ctrl+d.
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.
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.
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.
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With