Venv is not activated on already opened terminal on start up when `python.terminal.activateEnvInCurrentTerminal` is `true`

See original GitHub issue

Issue Type: Bug

Below is my settings.json:

{
    "terminal.integrated.shellArgs.windows": [
        "-NoLogo"
    ],
    "workbench.startupEditor": "none",
    "editor.formatOnSave": true,
    "editor.formatOnPaste": true,
    "editor.formatOnType": true,
    "code-runner.runInTerminal": true,
    "code-runner.saveFileBeforeRun": true,
    "workbench.panel.defaultLocation": "right",
    "terminal.integrated.copyOnSelection": true,
    "python.languageServer": "Pylance",
    "python.pythonPath": "C:/Users/AmericaN/Desktop/Lab/MyEnv/Scripts/python.exe",
    "code-runner.executorMap": {
        "python": "$pythonPath -u $fullFileName"
    },
    "code-runner.ignoreSelection": true,
    "remote.SSH.remotePlatform": {
        "My": "linux"
    },
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    "python.autoComplete.addBrackets": true,
    "python.terminal.activateEnvInCurrentTerminal": true,
    "files.exclude": {
        "**/.vscode": true,
        "**/MyEnv": true
    },
    "code-runner.showExecutionMessage": false,
    "python.analysis.completeFunctionParens": true,
    "workbench.editorAssociations": [
        {
            "viewType": "jupyter.notebook.ipynb",
            "filenamePattern": "*.ipynb"
        }
    ],
    "python.showStartPage": false
}
  1. open any .py file and leave the intergrated termianl open.
  2. close and reopen vscode.
  3. you will find that the enviroment is not activated.

But if i closed the terminal and reopened it again, so the enviroment will be activated.

And here’s the log from Python log:

User belongs to experiment group 'pythonaa'
User belongs to experiment group 'pythonSendEntireLineToREPL'
User belongs to experiment group 'pythonNotDisplayLinterPrompt'
User belongs to experiment group 'pythonDiscoveryModulecf'
User belongs to experiment group 'pythonTensorboardExperimentcf'
User belongs to experiment group 'PythonPyTorchProfiler'
User belongs to experiment group 'ShowExtensionSurveyPrompt - enabled'
User belongs to experiment group 'CollectLSRequestTiming - control'
> conda --version
> pyenv root
> python3.7 c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python2 c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -3.7 c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -3.6 c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -3 c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> py -2 c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> c:\Users\AmericaN\Desktop\Lab\MyEnv\Scripts\python.exe c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> conda info --json
Python interpreter path: .\MyEnv\Scripts\python.exe
Starting Pylance language server.
Error 2021-03-28 05:27:16: Detection of Python Interpreter for Command py and args -3.6 failed as file Python 3.6 not found!

 -3.9-64 does not exist
Error 2021-03-28 05:27:16: Detection of Python Interpreter for Command py and args -3.7 failed as file Python 3.7 not found!

 -3.9-64 does not exist
Error 2021-03-28 05:27:16: Detection of Python Interpreter for Command python3 and args  failed as file  does not exist
Error 2021-03-28 05:27:16: Detection of Python Interpreter for Command py and args -2 failed as file Python 2 not found!

 -3.9-64 does not exist
Error 2021-03-28 05:27:16: Failed to get interpreter information for 'C:\Users\AmericaN\AppData\Local\Microsoft\WindowsApps\python.exe' [Error: Command failed: "C:\\Users\AmericaN\AppData\Local\Microsoft\WindowsApps\python.exe" "c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py" "c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\interpreterInfo.py"
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

	at ChildProcess.exithandler (child_process.js:312:12)
	at ChildProcess.emit (events.js:315:20)
	at maybeClose (internal/child_process.js:1021:16)
	at Socket.<anonymous> (internal/child_process.js:443:11)
	at Socket.emit (events.js:315:20)
	at Pipe.<anonymous> (net.js:674:12)] {
  killed: false,
  code: 9009,
  signal: null,
  cmd: '"C:\\\\Users\\AmericaN\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe" "c:\\Users\\AmericaN\\.vscode\\extensions\\ms-python.python-2021.3.680753044\\pythonFiles\\pyvsc-run-isolated.py" "c:\\Users\\AmericaN\\.vscode\\extensions\\ms-python.python-2021.3.680753044\\pythonFiles\\interpreterInfo.py"'
}
Error 2021-03-28 05:27:16: Failed to get interpreter information for 'C:\Users\AmericaN\AppData\Local\Microsoft\WindowsApps\python3.exe' [Error: Command failed: "C:\\Users\AmericaN\AppData\Local\Microsoft\WindowsApps\python3.exe" "c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py" "c:\Users\AmericaN\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\interpreterInfo.py"
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

	at ChildProcess.exithandler (child_process.js:312:12)
	at ChildProcess.emit (events.js:315:20)
	at maybeClose (internal/child_process.js:1021:16)
	at Socket.<anonymous> (internal/child_process.js:443:11)
	at Socket.emit (events.js:315:20)
	at Pipe.<anonymous> (net.js:674:12)] {
  killed: false,
  code: 9009,
  signal: null,
  cmd: '"C:\\\\Users\\AmericaN\\AppData\\Local\\Microsoft\\WindowsApps\\python3.exe" "c:\\Users\\AmericaN\\.vscode\\extensions\\ms-python.python-2021.3.680753044\\pythonFiles\\pyvsc-run-isolated.py" "c:\\Users\\AmericaN\\.vscode\\extensions\\ms-python.python-2021.3.680753044\\pythonFiles\\interpreterInfo.py"'
}
> conda --version

Extension version: 2021.3.680753044 VS Code version: Code 1.54.3 (2b9aebd5354a3629c3aba0a5f5df49f43d6689f8, 2021-03-15T10:55:45.459Z) OS version: Windows_NT x64 10.0.19042

System Info
Item Value
CPUs Intel® Core™ i7-7700HQ CPU @ 2.80GHz (8 x 2808)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: enabled
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.86GB (7.83GB free)
Process Argv –crash-reporter-id b6c0830d-6a13-4115-8888-7dc0b49df85d
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
pythonvspyt700cf:30270857
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry244:30276681
pythonvsdeb440:30248342
pythonvsded773:30248341
pythonvspyt875:30259475
pythonvsnew554cf:30280384
pythontbcf:30265426
vspre833:30267464
pythonptprofiler:30281270
vshan820cf:30276953

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:60

github_iconTop GitHub Comments

1reaction
Kurt-von-Lavencommented, Jun 28, 2021

Yes, although on Mac OS X, one would have to actually quit the program since Mac OS X leaves programs open by default. Anyways, just food for thought if you notice something funny in the future.

1reaction
karrtikrcommented, May 27, 2021

Yes, actually the setting is only available in User scope. You can use Open User settings command from the command palette and set it there. Appreciate the effort!

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - VS Code integrated terminal not starting with virtual ...
"python.terminal.activateEnvInCurrentTerminal": true,. so I my global settings.json , F1 > preference: Open Settings (JSON) "python.
Read more >
Python Virtual Environments: A Primer
In this tutorial, you'll learn how to work with Python's venv module to create and manage separate virtual environments for your Python ......
Read more >
How To Set Up a Virtual Python Environment (Windows)
virtualenv is a tool to create isolated Python environments. ... This article provides a quick summary to help you set up and use...
Read more >
Settings Reference for Python - Visual Studio Code
Specifies whether to activate the currently open terminal when the Python extension is activated, using the virtual environment selected. logging.level, error ...
Read more >
Efficient Way to Activate Conda in VSCode - Medium
I was struggling quite a bit while I started using VSCode, because there is a ... On the top right corner, there is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found