Skip to content

Virtual environment not active in new powershell terminal #22916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ewdyang opened this issue Feb 14, 2024 · 8 comments
Closed

Virtual environment not active in new powershell terminal #22916

ewdyang opened this issue Feb 14, 2024 · 8 comments
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@ewdyang
Copy link

ewdyang commented Feb 14, 2024

Type: Bug

Behaviour

Expected vs. Actual

Expected: Currently selected virtual environment from python interpreter selection should be active when a new python terminal is created using Python: Create Terminal

Actual: Virtual environment is not active when new terminal is created.

Steps to reproduce:

  1. Activate a virtual environment using Python: Select Interpreter
  2. Create a new terminal using Python: Create Terminal

Diagnostic data

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

Terminal hover window:
image

Running $env:PATH or #env:path in the powershell terminal that should have the virtual environment active gives following output:

C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\ImageMagick-7.1.1-Q16-HDRI;C:\Program Files\ImageMagick-7.1.0-Q16-HDRI;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\compiler;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Calibre2\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\extras\CUPTI\lib64;C:\Program Files\nTopology\nTopology\;C:\Program 
Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\MATLAB\R2023b\bin;C:\Program Files\dotnet\;C:\Users\user name\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\user name\AppData\Local\Programs\Python\Python312\;C:\Users\user name\AppData\Local\Microsoft\WindowsApps;C:\Users\user name\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\user name\AppData\Local\GitHubDesktop\bin;C:\Users\user name\AppData\Local\Pandoc\;
PS D:\Documents\MSAM\Microscope Computer Vision Code> 

Contents of Enivronment changes from showing environment contributions of the relevant terminal:

# Terminal Environment Changes

## Extension: ms-python.python

Activated environment for `.\.venv\Scripts\python.exe`

- `PATH=c:\Users\user name\.vscode\extensions\ms-python.python-2024.0.1\pythonFiles\deactivate\powershell;D:\Documents\MSAM\Microscope Computer Vision Code\.venv\Scripts;${env:PATH}`
- `PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL`
- `PSMODULEPATH=D:\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules\`
- `PYTHONIOENCODING=utf-8`
- `PYTHONUNBUFFERED=1`
- `VIRTUAL_ENV=D:\Documents\MSAM\Microscope Computer Vision Code\.venv`
- `VIRTUAL_ENV_PROMPT=.venv`
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2024-02-14 15:28:09.458 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-02-14 15:28:09.458 [info] Experiment 'pythonREPLSmartSend' is active
2024-02-14 15:28:09.458 [info] Experiment 'pythonSurveyNotification' is active
2024-02-14 15:28:09.458 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-02-14 15:28:09.458 [info] Experiment 'pythonTestAdapter' is active
2024-02-14 15:28:09.489 [info] Default formatter is set to null for workspace d:\Documents\MSAM\Microscope Computer Vision Code
2024-02-14 15:28:09.518 [info] Test server listening.
2024-02-14 15:28:09.702 [info] Python interpreter path: .\.venv\Scripts\python.exe
2024-02-14 15:28:09.776 [info] > & "d:/Documents/MSAM/Microscope Computer Vision Code/.venv/Scripts/Activate.ps1" ; echo 'e8b39361-0157-4923-80e1-22d70d46dee6' ; python "c:/Users/user name/.vscode/extensions/ms-python.python-2024.0.1/pythonFiles/printEnvVariables.py"
2024-02-14 15:28:09.776 [info] shell: powershell
2024-02-14 15:28:09.814 [info] > conda info --json
2024-02-14 15:28:09.840 [info] > "d:/Documents/MSAM/Microscope Computer Vision Code/.venv/Scripts/activate.bat" && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python "c:/Users/user name/.vscode/extensions/ms-python.python-2024.0.1/pythonFiles/printEnvVariables.py"
2024-02-14 15:28:09.840 [info] shell: commandPrompt
2024-02-14 15:28:10.357 [info] > C:\Users\user name\AppData\Local\Microsoft\WindowsApps\python3.9.exe "c:/Users/user name/.vscode/extensions/ms-python.python-2024.0.1/pythonFiles/printEnvVariables.py"
2024-02-14 15:28:10.357 [info] shell: powershell
2024-02-14 15:28:10.712 [info] Send text to terminal: & "C:/Users/user name/AppData/Local/Microsoft/WindowsApps/python3.9.exe" "c:\Users\user name\.vscode\extensions\ms-python.python-2024.0.1\pythonFiles\printEnvVariablesToFile.py" "c:\Users\user name\.vscode\extensions\ms-python.python-2024.0.1\pythonFiles\deactivate\powershell\envVars.txt"
2024-02-14 15:28:11.019 [info] Starting Pylance language server.
2024-02-14 15:28:48.810 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-02-14 15:28:48.810 [info] Experiment 'pythonREPLSmartSend' is active
2024-02-14 15:28:48.810 [info] Experiment 'pythonSurveyNotification' is active
2024-02-14 15:28:48.810 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-02-14 15:28:48.810 [info] Experiment 'pythonTestAdapter' is active
2024-02-14 15:28:48.810 [info] Default formatter is set to null for workspace d:\Documents\MSAM\Microscope Computer Vision Code
2024-02-14 15:28:48.814 [info] Test server listening.
2024-02-14 15:28:48.819 [info] Python interpreter path: .\.venv\Scripts\python.exe
2024-02-14 15:28:49.039 [info] > & "d:/Documents/MSAM/Microscope Computer Vision Code/.venv/Scripts/Activate.ps1" ; echo 'e8b39361-0157-4923-80e1-22d70d46dee6' ; python "c:/Users/user name/.vscode/extensions/ms-python.python-2024.0.1/pythonFiles/printEnvVariables.py"
2024-02-14 15:28:49.039 [info] shell: powershell
2024-02-14 15:28:49.078 [info] > conda info --json
2024-02-14 15:28:49.110 [info] > "d:/Documents/MSAM/Microscope Computer Vision Code/.venv/Scripts/activate.bat" && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python "c:/Users/user name/.vscode/extensions/ms-python.python-2024.0.1/pythonFiles/printEnvVariables.py"
2024-02-14 15:28:49.110 [info] shell: commandPrompt
2024-02-14 15:28:49.453 [info] > C:\Users\user name\AppData\Local\Microsoft\WindowsApps\python3.9.exe "c:/Users/user name/.vscode/extensions/ms-python.python-2024.0.1/pythonFiles/printEnvVariables.py"
2024-02-14 15:28:49.454 [info] shell: powershell
2024-02-14 15:28:49.776 [info] Send text to terminal: & "C:/Users/user name/AppData/Local/Microsoft/WindowsApps/python3.9.exe" "c:\Users\user name\.vscode\extensions\ms-python.python-2024.0.1\pythonFiles\printEnvVariablesToFile.py" "c:\Users\user name\.vscode\extensions\ms-python.python-2024.0.1\pythonFiles\deactivate\powershell\envVars.txt"
2024-02-14 15:28:50.123 [info] Starting Pylance language server.

User Settings


languageServer: "Pylance"

Extension version: 2024.0.1
VS Code version: Code 1.86.1 (31c37ee8f63491495ac49e43b8544550fbae4533, 2024-02-07T09:08:20.941Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs AMD Ryzen 5 5600X 6-Core Processor (12 x 3693)
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: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.95GB (19.34GB free)
Process Argv --crash-reporter-id 5a28bdd8-fa5f-44d4-94bc-3f25b8361447
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:30962250
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
pydisww2:30959801
fegfb526:30961430
3ef8e399:30964150
e3gdj431:30958358
ccp2r6:30958158

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 14, 2024
@ewdyang
Copy link
Author

ewdyang commented Feb 14, 2024

Seems similar to #22888 but terminal doesn't say that shell integration failed to activate.
Could also be same cause as #22894

@karrtikr
Copy link

Please try out the pre-release version of the extension, you can use the following:

image

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 15, 2024
@abf7d
Copy link

abf7d commented Feb 16, 2024

Hi @karrtikr , It did not fix the problem

@ewdyang
Copy link
Author

ewdyang commented Feb 16, 2024

Please try out the pre-release version of the extension, you can use the following:

image

The pre-release fixed the problem for me, the virtual environment is active in the new terminal as expected.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 16, 2024
@abf7d
Copy link

abf7d commented Feb 22, 2024

Hi @karrtikr, do you have any other recommendations for me? This didn't fix the issue.

@karrtikr
Copy link

Your issue might be different, please open up a new one and we'll be happy to have a look, make sure to provide the debug logs asked earlier.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 22, 2024
@karrtikr karrtikr removed the info-needed Issue requires more information from poster label Feb 22, 2024
@abf7d
Copy link

abf7d commented Feb 22, 2024

Sorry, I had an issue opened and it took awhile to respond. Here's the link:
#22894

@karrtikr
Copy link

The pre-release fixed the problem for me, the virtual environment is active in the new terminal as expected.

Thanks, closing this in that case.

@abf7d Apologies, I'll reach back out to you on your issue soon.

@karrtikr karrtikr closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants