Skip to content

Virtual enviroment is not set correctly in Terminal #25185

Open
@gullevek

Description

@gullevek

Type: Bug

Behaviour

When a virtual enviroment is set, and also correctly selected for the python files, opening a terminal will have the virtual enviroment only half set.

There is a ".venv" listed in front of the prompt, sometimes even a "(.venv)" and the VIRTUAL_ENV is also set, but checking the path shows the wrong python

Steps to reproduce:

Have a virtual enviroment in python

python3 -m venv .venv
source .venv/bin/activate

Have this selected as the default python enterprator

Open a terminal and it will show

.venv[USER@HOST:PATH]$ echo $VIRTUAL_ENV
<CORRET PATH TO .venv folder>
.venv[USER@HOST:PATH]$ which python
<WRONG PATH TO python>
.venv[USER@HOST:PATH]$ source .venv/bin/activate
(.venv) .venv[USER@HOST:PATH]$ echo $VIRTUAL_ENV
<CORRET PATH TO .venv folder>
(.venv) .venv[USER@HOST:PATH]$ which python
<CORRECT PATH TO python>

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2025-06-17 10:42:25.070 [info] Experiment 'pythonRecommendTensorboardExt' is active
2025-06-17 10:42:25.070 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2025-06-17 10:42:25.070 [info] Native locator: Refresh started
2025-06-17 10:42:25.417 [info] > pyenv which python
2025-06-17 10:42:25.417 [info] cwd: ~/Path/To/Project
2025-06-17 10:42:26.355 [info] Pyenv environment manager found at: /opt/homebrew/bin/pyenv
2025-06-17 10:42:26.523 [info] Python interpreter path: ./.venv/bin/python
2025-06-17 10:42:26.724 [info] > . "~/Path/To/Project/.venv/bin/activate" && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2025.8.0-darwin-arm64/python_files/printEnvVariables.py
2025-06-17 10:42:26.724 [info] shell: zsh
2025-06-17 10:42:26.804 [info] > /opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin/python3 ~/.vscode/extensions/ms-python.python-2025.8.0-darwin-arm64/python_files/printEnvVariables.py
2025-06-17 10:42:26.804 [info] shell: zsh
2025-06-17 10:42:26.895 [info] Prepending environment variable PATH in collection with /Users/USER.NAME/.vscode/extensions/ms-python.python-2025.8.0-darwin-arm64/python_files/deactivate/zsh:/Users/USER.NAME/Path/To/Project/.venv/bin: {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2025-06-17 10:42:26.895 [info] Setting environment variable VIRTUAL_ENV in collection to /Users/USER.NAME/Path/To/Project/.venv {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2025-06-17 10:42:26.895 [info] Setting environment variable VIRTUAL_ENV_PROMPT in collection to .venv {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2025-06-17 10:42:26.895 [info] Prepending environment variable PS1 in collection with .venv {"applyAtShellIntegration":true,"applyAtProcessCreation":false}
2025-06-17 10:42:26.895 [info] Send text to terminal: /opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin/python3 /Users/USER.NAME/.vscode/extensions/ms-python.python-2025.8.0-darwin-arm64/python_files/printEnvVariablesToFile.py /Users/USER.NAME/.vscode/extensions/ms-python.python-2025.8.0-darwin-arm64/python_files/deactivate/zsh/envVars.txt
2025-06-17 10:42:26.986 [info] Native locator: Refresh finished in 2064 ms
2025-06-17 10:42:28.330 [info] Starting Pylance language server.
2025-06-17 10:42:30.338 [info] > conda info --json
2025-06-17 10:42:32.410 [info] Native locator: Refresh started
2025-06-17 10:42:32.424 [info] Pyenv environment manager found at: /opt/homebrew/bin/pyenv
2025-06-17 10:42:33.005 [info] Native locator: Refresh finished in 594 ms
2025-06-17 10:45:19.572 [info] Native locator: Refresh started
2025-06-17 10:45:19.582 [info] Pyenv environment manager found at: /opt/homebrew/bin/pyenv
2025-06-17 10:45:20.073 [info] Native locator: Refresh finished in 500 ms
2025-06-17 10:48:42.510 [info] Discover tests for workspace name: undefined - uri: /Users/USER.NAME/Library/Application Support/Code/User/settings.json
2025-06-17 10:48:57.750 [info] Discover tests for workspace name: undefined - uri: /Users/USER.NAME/Library/Application Support/Code/User/settings.json
2025-06-17 10:49:17.454 [info] Discover tests for workspace name: undefined - uri: /Users/USER.NAME/Library/Application Support/Code/User/settings.json

Extension version: 2025.8.0
VS Code version: Code 1.101.0 (Universal) (dfaf44141ea9deb3b4096f7cd6d24e00c147a4b1, 2025-06-11T15:00:50.123Z)
OS version: Darwin arm64 24.5.0
Modes:
Connection to 'SSH: soba' could not be established Connecting with SSH timed out
Connection to 'SSH: soba' could not be established Canceled
Connection to 'SSH: soba' could not be established Connecting with SSH timed out
Connection to 'SSH: soba' could not be established Canceled
Connection to 'SSH: kome' could not be established Connecting with SSH timed out

  • Python version (& distribution if applicable, e.g. Anaconda): 3.13.5
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Pylance
User Settings


languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
auto-close-tag for 0.5.15
auto-complete-tag for 0.1.0
auto-rename-tag for 0.1.10
autodocstring njp 0.6.1
azure-repos ms- 0.40.0
base16-tinted-themes Tin 0.24.0
bash-ide-vscode mad 1.43.0
better-perl-syntax jef 1.0.14
better-shellscript-syntax jef 1.10.0
black-formatter ms- 2025.2.0
Bookmarks ale 13.5.0
boto3-ide Bot 0.6.0
color-highlight nau 2.8.0
cuesheet zgm 0.4.0
dark-plus-syntax dun 0.2.11
debugpy ms- 2025.8.0
docker doc 0.10.0
dotenv mik 1.0.1
EditorConfig Edi 0.17.4
eml lei 0.4.0
errorlens use 3.26.0
even-better-toml tam 0.21.2
explorer vit 1.24.3
flake8 ms- 2025.2.0
ginfuru-better-solarized-dark-theme gin 0.10.9
git-graph mhu 1.30.0
git-log--graph phi 0.1.23
githistory don 0.6.20
gitlens eam 17.1.1
go gol 0.46.1
hexeditor ms- 1.11.1
highlight-matching-tag vin 0.11.0
html-css-class-completion Zig 1.20.0
i18n-ally lok 2.13.1
indent-rainbow ode 8.3.1
intellicode-api-usage-examples Vis 0.2.9
isort ms- 2025.0.0
js-debug ms- 1.100.1
js-debug-companion ms- 1.1.3
jupyter ms- 2025.5.0
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.1.0
language-gettext mro 0.5.0
latte Kas 0.18.0
live-server ms- 0.4.15
lnav lna 0.1.0
macos-modern-theme dav 2.3.19
markdown-all-in-one yzh 3.6.3
material-icon-theme PKi 5.23.0
material-theme zhu 3.19.0
monokai-st3 And 0.2.0
one-dark-pro-monokai-darker ese 1.1.0
pdf tom 1.2.2
perl ric 2.6.2
pgn jak 1.0.2
php-debug xde 1.36.1
php-docblocker nei 2.7.0
phpcs she 1.0.8
pylint ms- 2025.2.0
python ms- 2025.8.0
rainbow-csv mec 3.19.0
remote-containers ms- 0.417.0
remote-explorer ms- 0.5.0
remote-repositories ms- 0.42.0
remote-server ms- 1.5.2
remote-ssh ms- 0.120.0
remote-ssh-edit ms- 0.87.0
remote-wsl ms- 0.99.0
remotehub Git 0.64.0
rest-client hum 0.25.1
ruff cha 2025.22.0
rust-analyzer rus 0.3.2500
rust-extension-pack wol 0.1.1
shellcheck tim 0.37.7
shfmt mkh 1.3.1
smarty-template-support asw 2.1.1
solarized rya 2.6.0
sublime-keybindings ms- 4.1.10
svg joc 1.5.4
svg-preview Sim 2.8.3
test-adapter-converter ms- 0.2.1
theme-material-theme jpr 1.0.1
todo-tree Gru 0.0.226
trailing-spaces sha 0.4.1
vscode-apache mrm 1.2.0
vscode-containers ms- 2.0.3
vscode-docker ms- 2.0.0
vscode-duplicate mrm 1.2.1
vscode-edit-csv jan 0.11.4
vscode-eslint dba 3.0.10
vscode-filesize mkx 3.2.2
vscode-github-actions git 0.27.2
vscode-html-css ecm 2.0.13
vscode-icons vsc 12.13.0
vscode-intelephense-client bme 1.14.4
vscode-js-profile-table ms- 1.0.10
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
vscode-language-pack-ja MS- 1.101.2025061109
vscode-markdownlint Dav 0.60.0
vscode-peacock joh 4.2.2
vscode-perl cfg 1.19.0
vscode-pgsql ms- 1.4.2
vscode-phpunit rec 3.7.10
vscode-pull-request-github Git 0.110.0
vscode-pylance ms- 2025.6.1
vscode-quick-select dba 0.2.9
vscode-remote-extensionpack ms- 0.26.0
vscode-rust-syntax dun 0.0.32
vscode-rust-test-adapter Swe 0.11.0
vscode-test-explorer hbe 2.22.1
vscode-versionlens pfl 1.22.2
vscode-yaml red 1.18.0
vscodeintellicode Vis 1.3.2
System Info
Item Value
CPUs Apple M1 Max (10 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 9, 10, 11
Memory (System) 64.00GB (0.18GB free)
Process Argv --crash-reporter-id c08ac814-7444-4d49-92b6-4722e893ed0d
Screen Reader no
VM 0%

Connection to 'SSH: soba' could not be established Connecting with SSH timed out

Connection to 'SSH: soba' could not be established Canceled

Connection to 'SSH: soba' could not be established Connecting with SSH timed out

Connection to 'SSH: soba' could not be established Canceled

Connection to 'SSH: kome' could not be established Connecting with SSH timed out

A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vscod805:30301674
binariesv615:30325510
vscaac:30438847
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupyter:31046869
pythonrstrctxt:31112756
nativeloc1:31192215
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
e5gg6876:31282496
pythoneinst12:31285622
bgtreat:31268568
4gafe986:31271826
c7cif404:31314491
pythonpulldiagcf:31325931
996jf627:31283433
pythonrdcb7:31303018
usemplatestapi:31297334
0aa6g176:31307128
7bj51361:31289155
747dc170:31275177
6518g693:31325878
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
jhi8h917:31327034
1292j425:31329156

Metadata

Metadata

Assignees

Labels

area-terminalbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions