skip to Main Content

I have a project in VSCode 1.86.2 on Windows 10 where it used to open terminals with venv automatically activated. Very handy.

It stopped working and I have not been able to turn this feature back on. There is no associated error message.

Setup

My pseudo path is like:

A pseudo path looks like:

C/
├─ Users/
├─ AlGrant/
│  ├─ test_pyrtlsdr/ 
│  │  ├─ .vscode/
│  │  │  ├─ settings.json
│  │  ├─ .venv/
│  │  │  ├─ Scripts/
│  │  │  │  ├─ python.exe
│  │  ├─ src/

Answers Searched

#1

I have tried to reactivate this feature by following this post which called for me to edit settings.json in .vscode directory and to add:

"python.terminal.activateEnvironment": true 

or the second answer suggested:

"settings": {
"python.terminal.activateEnvInCurrentTerminal": true,
"python.defaultInterpreterPath": "~/venv/bin/python"
}

or even :

{
"python.terminal.activateEnvInCurrentTerminal": true,
"python.defaultInterpreterPath": "~/venv/bin/python"
}

Neither of those options worked. I presume on windows the path should be written : "/.venv/Scripts/python.exe" instead of bin? (which I tried)

#2

Another post here stated that the setting should be :

    {
       "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
    }

Again I also tried :

    {
       "python.defaultInterpreterPath": "${workspaceFolder}/.venv/Scripts/python"
    }

#3

And yet another post here suggested setting it vai the settings cog (bottom right):

enter image description here

And I added it like:

enter image description here

I note this settings file is located in the AppDataRoamingCodeUser folder (not project folder).

Does venv work

I have confirmed that I can manually activate the venv from command prompt – so thats not broken.

I note that the bottom right of VSCode suggests that it is using venv:

enter image description here

How can I have new terminals in VSCode activate the venv?

2

Answers


  1. Chosen as BEST ANSWER

    It appears this feature has been removed from the latest version of the VSCode Python plugin.

    You can still check what evenv you are in by hovering over the terminal.

    enter image description here

    It has been raised as an issue here : https://github.com/microsoft/vscode-python/issues/22917

    And Further information about how to check which venv your in is here : https://github.com/microsoft/vscode-python/wiki/Activate-Environments-in-Terminal-Using-Environment-Variables


  2. I’ve been having the same issue and found that if you execute which python on your terminal window, you can validate which interpreter is being used (global or venv).

    It’s not as visual or friendly, but hope it helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search