Skip to content

Virtual Environment not activated when PowerShell execution is disabled #22252

Description

@weeix

Type: Bug

Behaviour

Expected vs. Actual

  • Expected: Virtual Environment activated, or show warnings if it can't.
  • Actual: Virtual Environment failed to activate silently.

Steps to reproduce:

  1. Set PowerShell as default terminal
  2. Create a virtual environment
  3. Select the virtual environment as interpreter
  4. Delete the terminal and open it again

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.0
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2023-10-18 19:48:57.027 [info] Experiment 'pythonPromptNewFormatterExt' is active
2023-10-18 19:48:57.027 [info] Experiment 'pythonPromptNewToolsExt' is active
2023-10-18 19:48:57.027 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2023-10-18 19:48:57.027 [info] Experiment 'pythonTestAdaptercf' is active
2023-10-18 19:48:57.027 [info] Test server listening.
2023-10-18 19:48:57.027 [info] Python interpreter path: .\.venv\Scripts\python.exe
2023-10-18 19:48:57.421 [info] > & ./.venv/Scripts/Activate.ps1 ; echo 'e8b39361-0157-4923-80e1-22d70d46dee6' ; python ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/printEnvVariables.py
2023-10-18 19:48:57.421 [info] shell: powershell
2023-10-18 19:48:58.331 [info] Starting Pylance language server.
2023-10-18 19:48:58.621 [warning] Got env variables but with errors & : File C:\Users\username\Downloads\geonode\.venv\Scripts\Activate.ps1 cannot be loaded because running scripts is 
disabled on this system. For more information, see about_Execution_Policies at 
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ & c:/Users/username/Downloads/geonode/.venv/Scripts/Activate.ps1 ; echo  ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

2023-10-18 19:48:58.627 [info] > ~\AppData\Local\Programs\Python\Python312\python.exe ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/printEnvVariables.py
2023-10-18 19:48:58.627 [info] shell: powershell

User Settings


languageServer: "Pylance"

Extension version: 2023.18.0
VS Code version: Code 1.83.1 (f1b07bd25dfad64b0167beb15359ae573aecd2cc, 2023-10-10T23:48:05.904Z)
OS version: Windows_NT x64 10.0.22621
Modes:

System Info
Item Value
CPUs 12th Gen Intel(R) Core(TM) i5-12400F (12 x 2496)
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.82GB (23.29GB free)
Process Argv --crash-reporter-id bbcd2996-e4f0-42dc-994d-6bf9429cf1e3
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263cf:30856253
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
3biah626:30602489
89544117:30613380
a9j8j154:30646983
showlangstatbar:30737416
962ge761:30841074
a2ce3375:30757347
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxptcf:30805731
pythonnoceb:30805159
copilotsettingt:30859503
synctok:30821570
dsvsc013:30795093
dsvsc014:30804076
diffeditorv1:30821571
pythonmpsinfo:30842941
dsvsc015:30845448
pyreplss2:30858576
pythontbext0:30864172

Metadata

Metadata

Assignees

Labels

area-terminalbugIssue identified by VS Code Team member as probable bugexperimentingFeature is part of an experimentverifiedVerification succeededwindows

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions