question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not auto entering virtualenv in terminal when reopening python project

See original GitHub issue

Type: Bug

  1. Create a project folder, and initialize a python virtualenv inside the folder python -m venv venv
  2. Open the folder with Vscode.
  3. Vscode will recognize the venv and help activate it.
  4. Open the Vscode terminal(default to Powershell), Vscode will auto executing the activation script, so far so good.
  5. Close Vscode leaving the terminal open. (So when reopening, Vscode will open the terminal.)
  6. Problem occurred. The auto-opened terminal does not auto run the venv activation script.

VS Code version: Code 1.71.0 (784b0177c56c607789f9638da7b6bf3230d47a8c, 2022-09-01T07:36:10.600Z) OS version: Windows_NT x64 10.0.22000 Modes: Sandboxed: No

System Info
Item Value
CPUs AMD Ryzen 7 5800X 8-Core Processor (16 x 4200)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
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_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 31.89GB (22.12GB free)
Process Argv –crash-reporter-id c5f0bbb5-7513-40b1-9a60-993d4deb0b8c
Screen Reader no
VM 0%
Extensions (29)
Extension Author (truncated) Version
rainbow-brackets 2gu 0.0.6
vscode-sqlite ale 0.14.1
gotemplate cas 0.4.0
doxdocgen csc 1.4.0
es7-react-js-snippets dsz 4.4.3
vscode-go-syntax dun 0.0.18
vsc-material-theme Equ 33.5.0
vsc-material-theme-icons equ 2.3.1
copilot Git 1.44.6735
go gol 0.35.2
gc-excelviewer Gra 4.2.55
better-cpp-syntax jef 1.15.19
intellij-idea-keybindings k– 1.5.2
rainbow-csv mec 3.0.0
language-gettext mro 0.2.0
vscode-docker ms- 1.22.1
vscode-language-pack-zh-hans MS- 1.71.9070915
python ms- 2022.14.0
vscode-pylance ms- 2022.9.10
jupyter ms- 2022.8.1002431955
jupyter-keymap ms- 1.0.0
remote-containers ms- 0.251.0
cmake-tools ms- 1.12.27
cpptools ms- 1.12.4
cpptools-extension-pack ms- 1.3.0
makefile-tools ms- 0.6.0
powershell ms- 2022.8.5
autodocstring njp 0.6.1
cmake twx 0.0.17

(1 theme extensions excluded)

A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30557515
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
pylanb8912:30545647
vsclangdc:30486549
c4g48928:30535728
hb751961:30553087
dsvsc012:30540252
azure-dev_surveyone:30548225
i497e931:30553904

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
PaRaD1SE98commented, Sep 14, 2022

See #19610. Try setting "python.terminal.activateEnvInCurrentTerminal" to true.

This solved my problem.

0reactions
karrtikrcommented, Sep 14, 2022

@amirhfro Please open a new issue using the Python: Report Issue command as your cause is likely different. Also try setting terminal.integrated.enablePersistentSessions to true in User settings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto activate virtual environment in Visual Studio Code
Enter Ctrl + Shift + P in your vs code. Locate your Virtual Environment: Python: select interpreter > Enter interpreter path > Find....
Read more >
Pycharm Terminal fails to activate virtual env
When I click Terminal, it does not activate the virtualenv environment. How to recreate: I create a new project, selecting the option to......
Read more >
Activate, Reactivate, Deactivate your Virtualenv - Blog Post
Here's a quick guide to activate your virtual environment (Virtualenv) -- especially if you closed your terminal window (aka command prompt).
Read more >
How to Activate python Virtual Environment in VS Code
In this video, we have learned how to activate python virtual environment in VS Code.
Read more >
Python Virtual Environments: A Primer
Now your project has its own virtual environment. ... As long as you don't close your terminal, every Python package that you'll install ......
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