'In VsCode, how to change the default path to run to activate venv in new terminals?
I am running Visual Studio Code in windows 10 environment.
I am trying to set up VsCode to activate venv when I create a new terminal or I open VsCode.
Here is some settings in .vscode/settings.json
"python.pythonPath": "venv\\Scripts\\python.exe",
"python.defaultInterpreterPath": "venv\\Scripts\\python.exe",
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvInCurrentTerminal": true,
The problem is it runs
c:/abs/path/to/project/venv/Scripts/Activate.ps1
that returns
& was unexpected at this time.
instead of
c:/abs/path/to/project/venv/Scripts/Activate
that activates the virtual environment
I am using company laptop with limited access so I can not have access to registry and fix it.
So, the question is, how to make VsCode use
c:\abs\path\to\project\venv\Scripts\Activate
Note: if I run c:/abs/path/to/project/venv/Scripts/Activate it activates venv for me
Solution 1:[1]
Is the venv a conda environment? If so, please note:
Note: conda environments cannot be automatically activated in the integrated terminal if PowerShell is set as the integrated shell. See Integrated terminal - Configuration for how to change the shell.
Source: https://code.visualstudio.com/docs/python/environments
You'll need to set your default integrated terminal to use command prompt -- please see: https://code.visualstudio.com/docs/editor/integrated-terminal#_terminal-profiles
E.g., add/replace this in your settings.json:
"terminal.integrated.defaultProfile.windows": "Command Prompt",
...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user18337734 |
