Skip to content

Cannot deactivate venv in terminal while venv/bin/python is interpreter #23449

Closed

Description

@k98kurz

Type: Bug

  1. Run the bash command python -m venv venv in the root directory.
  2. Run the "select python interpreter" command in VSCode and select "./venv/bin/python".
  3. Close all existing terminals in VSCode with the trash icon.
  4. Create a new terminal in VSCode.
  5. which python will show the local venv/bin/python path.
  6. deactivate results in an error "/home/username/.vscode/extensions/ms-python.python-2024.6.0/python_files/deactivate/bash/deactivate: Permission denied"

Being able to deactivate the venv is a necessary feature for development.

Extension version: 2024.6.0
VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:16:23.416Z)
OS version: Linux x64 6.5.0-35-generic snap
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz (8 x 2900)
GPU Status 2d_canvas: unavailable_software
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
webgpu: disabled_off
Load (avg) 6, 4, 4
Memory (System) 31.20GB (26.26GB free)
Process Argv --no-sandbox --force-user-env --crash-reporter-id 8288fe70-1d22-4ecb-a399-2ca5eb4778fd
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu-xorg
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu-xorg
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
tftest:31042121
vstes516:30244333
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:31000450
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
chatpanelc:31048052
dsvsc021:30996838
jg8ic977:31013176
pythoncenvpt:31049070
fchga941:31046352
dvdeprecation:31052039
pythonprc:31047982
dwnewjupytercf:31046870
26j00206:31048877

Activity

  1. HappyCoder77 commented on May 18, 2024

    @HappyCoder77

    I have the same problem It almost make crazy.

  2. s-kai273 commented on May 18, 2024

    @s-kai273

    although deactivate command should work, I'm wondering what the proper behavior is...
    when opening a new terminal, python default path should be global one?

  3. hnur-eris commented on May 21, 2024

    @hnur-eris

    I had same issue. First of all you need to delete virtual environment (./venv directory) on your path, and then try deactivate command once again.

  4. ilmari99 commented on May 27, 2024

    @ilmari99

    I don't know the underlying reason for the bug, but changing the permissions of the deactivate script worked for me: chmod u+x /home/username/.vscode/extensions/ms-python.python-2024.6.0/python_files/deactivate/bash/deactivate.

  5. michelmetran commented on May 27, 2024

    @michelmetran

    I don't know the underlying reason for the bug, but changing the permissions of the deactivate script worked for me: chmod u+x /home/username/.vscode/extensions/ms-python.python-2024.6.0/python_files/deactivate/bash/deactivate.

    I thank!
    Here I was having the same problem and by changing the permissions I managed to solve it!

  6. anthonykim1 commented on May 29, 2024

    @anthonykim1

    In a remote scenario there is the permission issue: #23195

    Jon Tyler (@k98kurz) Can you try with the enhanced permission referenced in #23195?

    Another way would be opting out of terminal env activation by adding:
    "python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"],
    in your settings.json

  7. k98kurz commented on May 30, 2024

    @k98kurz
    Author

    I can confirm that the permissions solution works

  8. added a commit that references this issue on Jun 17, 2024
    c066a3f
  9. added a commit that references this issue on Jun 24, 2024
    0b103a8
  10. added a commit that references this issue on Jun 28, 2024
    bfeabd1
  11. locked as resolved and limited conversation to collaborators on Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions