Skip to content
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

The virtual environment is not activated after restarting the workspace. #24558

Open
recsater opened this issue Dec 9, 2024 · 7 comments
Open
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team

Comments

@recsater
Copy link

recsater commented Dec 9, 2024

Type: Bug

Behaviour

Image

Steps to reproduce:

"The video can be summarized as follows:

By default, the virtual environment is not activated in a new terminal unless the interpreter is selected through the command palette.
Even if the interpreter is selected, the virtual environment is not activated in a new terminal after restarting the window.
After restarting the window, entering and exiting the Python extension tab will activate the virtual environment in a new terminal.
However, the virtual environment will still not activate after restarting the window unless the Python extension tab is accessed."

Diagnostic data

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

XXX

Extension version: 2024.20.0
VS Code version: Code 1.95.3 (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z)
OS version: Linux x64 6.8.0-49-generic
Modes:
Remote OS version: Linux x64 6.8.0-49-generic

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


languageServer: "Pylance"

experiments
• optOutFrom: ["pythonTerminalEnvVarActivation"]

Installed Extensions
Extension Name Extension Id Version
JavaScript Debugger ms-vscode.js-debug 1.95.3
Pylance ms-python.vscode-pylance 2024.12.1
Python ms-python.python 2024.20.0
Python Debugger ms-python.debugpy 2024.12.0
Python Environment Manager donjayamanne.python-environment-manager 1.2.4
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
System Info
Item Value
CPUs Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz (16 x 4600)
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: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off
Load (avg) 1, 1, 1
Memory (System) 62.73GB (29.26GB free)
Process Argv . --crash-reporter-id 3b34a8a1-42be-48ca-bf66-b7198c02f9c8
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu
XDG_SESSION_TYPE x11
Item Value
Remote Container xeye0324/ros:atd-34-plan_linux_amd64 (atd-34-plan_linux_amd64)
OS Linux x64 6.8.0-49-generic
CPUs Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz (16 x 4599)
Memory (System) 62.73GB (29.26GB free)
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
vscrpc:30673769
a9j8j154:30646983
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupytercf:31046870
newcmakeconfigv2:31071590
nativerepl1:31139838
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530

![Image](https://github.com/user-attachments/assets/9ec38505-aad1-4162-9520-86fb5d37f6c8)
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Dec 9, 2024
@karthiknadig
Copy link
Member

@recsater Do you have these two settings enabled?
Image

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Dec 9, 2024
@recsater
Copy link
Author

recsater commented Dec 9, 2024

@recsater Do you have these two settings enabled? Image

Actually, I have already tried the same test multiple times with those options set to true.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Dec 9, 2024
@karthiknadig karthiknadig self-assigned this Dec 10, 2024
@igormicadei
Copy link

I'm having the same issue since the last VSCode update.

Image

The two settings are enabled, the virtual environment is active, but any new terminal I open, unless I activate the virtual environment manually, it runs on global environment.

VSCode
-----------------------
Version:		1.96.0 (user setup)
Commit:			138f619c86f1199955d53b4166bef66ef252935c
Date:			2024-12-11T02:29:09.626Z
Electron:		32.2.6
ElectronBuildId:	10629634
Chromium:		128.0.6613.186
Node.js:		20.18.1
V8:			12.8.374.38-electron.0
OS:			Windows_NT x64 10.0.22631
OS
-----------------------
Edition			Windows 11 Pro
Version			23H2
Installed on		10/‎03/‎2024
OS build		22631.4460
Experience		Windows Feature Experience Pack 1000.22700.1047.0
Python Extension
-----------------------
Name:			Python
Id:			ms-python.python
Version: 		2024.22.0
Publisher: 		Microsoft

@karthiknadig
Copy link
Member

Please share your logs from Output > Python and Output > Python Locator. Also, provide the path to the virtual environment you are expecting it to activate.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Dec 13, 2024
@recsater
Copy link
Author

Please share your logs from Output > Python and Output > Python Locator. Also, provide the path to the virtual environment you are expecting it to activate.

  • Output > Python
2024-12-16 00:28:25.666 [info] Experiment 'pythonTerminalEnvVarActivation' is inactive
2024-12-16 00:28:25.666 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-12-16 00:28:25.666 [info] Experiment 'pythonTestAdapter' is active
2024-12-16 00:28:25.666 [info] Native locator: Refresh started
2024-12-16 00:28:25.666 [info] Native locator: Refresh started
2024-12-16 00:28:25.687 [info] Native locator: Refresh started
2024-12-16 00:28:25.694 [info] > pyenv which python
2024-12-16 00:28:25.694 [info] cwd: .
2024-12-16 00:28:25.702 [info] Native locator: Refresh finished in 158 ms
2024-12-16 00:28:25.704 [info] Python interpreter path: ./.venv/bin/python
2024-12-16 00:28:26.903 [info] Starting Pylance language server.
2024-12-16 00:28:53.975 [info] Native locator: Refresh started
2024-12-16 00:28:53.999 [info] Native locator: Refresh finished in 24 ms
2024-12-16 00:28:53.999 [info] Discover tests for workspace name: xeye - uri: /root/multipleye/xeye
2024-12-16 00:29:43.969 [info] Native locator: Refresh started
2024-12-16 00:29:43.996 [info] Native locator: Refresh finished in 26 ms
2024-12-16 00:30:07.560 [info] Native locator: Refresh started
2024-12-16 00:30:07.585 [info] Native locator: Refresh finished in 25 ms
2024-12-16 00:30:07.585 [info] Discover tests for workspace name: xeye - uri: /root/multipleye/xeye
2024-12-16 00:30:21.045 [info] Discover tests for workspace name: xeye - uri: /root/multipleye/xeye
2024-12-16 00:30:21.045 [info] Python interpreter path: ./xeye-python/.venv/bin/python
2024-12-16 00:30:26.368 [info] Send text to terminal: source /root/multipleye/xeye/xeye-python/.venv/bin/activate
  • Output > Python Locator
2024-12-16 00:28:25.666 [info] Starting Python Locator /root/.vscode-server/extensions/ms-python.python-2024.22.0-linux-x64/python-env-tools/bin/pet server
2024-12-16 00:28:25.667 [info] Discovered env: /root/multipleye/xeye/.venv/bin/python
2024-12-16 00:28:25.670 [info] Discovered env: /bin/python3
2024-12-16 00:28:25.670 [info] Discovered env: /usr/bin/python3
2024-12-16 00:28:25.701 [info] Locator Conda took 11.424103ms
2024-12-16 00:28:25.701 [info] Locator Homebrew took 39.425µs
2024-12-16 00:28:25.701 [info] Locator LinuxGlobal took 26.344585ms
2024-12-16 00:28:25.701 [info] Locator PipEnv took 10.091µs
2024-12-16 00:28:25.701 [info] Locator Poetry took 139.561µs
2024-12-16 00:28:25.701 [info] Locator PyEnv took 596.488µs
2024-12-16 00:28:25.701 [info] Locator Venv took 9.911µs
2024-12-16 00:28:25.701 [info] Locator VirtualEnv took 45.276µs
2024-12-16 00:28:25.701 [info] Locator VirtualEnvWrapper took 44.089µs
2024-12-16 00:28:25.701 [info] Locator GlobalVirtualEnvs took 126.829µs
2024-12-16 00:28:25.701 [info] Locator Locators took 27.025831ms
2024-12-16 00:28:25.701 [info] Locator Path took 52.687057ms
2024-12-16 00:28:25.701 [info] Locator Workspaces took 10.852594ms
2024-12-16 00:28:25.701 [info] Refresh completed in 52ms
2024-12-16 00:28:25.702 [info] Resolved Python Environment /root/multipleye/xeye/.venv/bin/python
2024-12-16 00:28:53.986 [info] Discovered env: /usr/bin/python3
2024-12-16 00:28:53.986 [info] Discovered env: /bin/python3
2024-12-16 00:28:53.996 [info] Locator Conda took 8.049926ms
2024-12-16 00:28:53.997 [info] Locator Homebrew took 33.856µs
2024-12-16 00:28:53.997 [info] Locator LinuxGlobal took 9.271333ms
2024-12-16 00:28:53.997 [info] Locator PipEnv took 14.864µs
2024-12-16 00:28:53.997 [info] Locator Poetry took 101.76µs
2024-12-16 00:28:53.997 [info] Locator PyEnv took 150.693µs
2024-12-16 00:28:53.997 [info] Locator Venv took 7.039µs
2024-12-16 00:28:53.997 [info] Locator VirtualEnv took 9.438µs
2024-12-16 00:28:53.997 [info] Locator VirtualEnvWrapper took 9.282µs
2024-12-16 00:28:53.997 [info] Locator GlobalVirtualEnvs took 46.451µs
2024-12-16 00:28:53.997 [info] Locator Locators took 9.986535ms
2024-12-16 00:28:53.997 [info] Locator Path took 20.585615ms
2024-12-16 00:28:53.997 [info] Locator Workspaces took 2.814169ms
2024-12-16 00:28:53.997 [info] Refresh completed in 20ms
2024-12-16 00:29:43.973 [info] Resolved Python Environment /root/multipleye/xeye/.venv/bin/python
2024-12-16 00:29:43.975 [info] Discovered env: /root/multipleye/xeye/.venv/bin/python
2024-12-16 00:29:43.982 [info] Discovered env: /usr/bin/python3
2024-12-16 00:29:43.982 [info] Discovered env: /bin/python3
2024-12-16 00:29:43.994 [info] Locator Conda took 9.369579ms
2024-12-16 00:29:43.995 [info] Locator Homebrew took 205.485µs
2024-12-16 00:29:43.995 [info] Locator LinuxGlobal took 10.227213ms
2024-12-16 00:29:43.995 [info] Locator PipEnv took 11.427µs
2024-12-16 00:29:43.995 [info] Locator Poetry took 259.846µs
2024-12-16 00:29:43.995 [info] Locator PyEnv took 122.523µs
2024-12-16 00:29:43.995 [info] Locator Venv took 16.513µs
2024-12-16 00:29:43.995 [info] Locator VirtualEnv took 14.214µs
2024-12-16 00:29:43.995 [info] Locator VirtualEnvWrapper took 37.886µs
2024-12-16 00:29:43.995 [info] Locator GlobalVirtualEnvs took 51.202µs
2024-12-16 00:29:43.995 [info] Locator Locators took 11.036992ms
2024-12-16 00:29:43.995 [info] Locator Path took 23.492232ms
2024-12-16 00:29:43.995 [info] Locator Workspaces took 4.24094ms
2024-12-16 00:29:43.995 [info] Refresh completed in 23ms
2024-12-16 00:30:07.571 [info] Discovered env: /usr/bin/python3
2024-12-16 00:30:07.571 [info] Discovered env: /bin/python3
2024-12-16 00:30:07.584 [info] Locator Conda took 8.684609ms
2024-12-16 00:30:07.584 [info] Locator Homebrew took 36.713µs
2024-12-16 00:30:07.584 [info] Locator LinuxGlobal took 9.381548ms
2024-12-16 00:30:07.584 [info] Locator PipEnv took 13.79µs
2024-12-16 00:30:07.584 [info] Locator Poetry took 293.026µs
2024-12-16 00:30:07.584 [info] Locator PyEnv took 145.671µs
2024-12-16 00:30:07.584 [info] Locator Venv took 8.892µs
2024-12-16 00:30:07.584 [info] Locator VirtualEnv took 12.702µs
2024-12-16 00:30:07.584 [info] Locator VirtualEnvWrapper took 10.233µs
2024-12-16 00:30:07.584 [info] Locator GlobalVirtualEnvs took 44.589µs
2024-12-16 00:30:07.584 [info] Locator Locators took 10.361131ms
2024-12-16 00:30:07.584 [info] Locator Path took 23.070999ms
2024-12-16 00:30:07.584 [info] Locator Workspaces took 2.64194ms
2024-12-16 00:30:07.584 [info] Refresh completed in 23ms
2024-12-16 00:30:21.044 [info] Resolved Python Environment /root/multipleye/xeye/xeye-python/.venv/bin/python
2024-12-16 00:31:19.527 [info] Resolved Python Environment /root/multipleye/xeye/xeye-python/.venv/bin/python

After reloading window, no Python output.

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

I have the same issue. Repros every time.

@eleanorjboyd eleanorjboyd added the bug Issue identified by VS Code Team member as probable bug label Dec 16, 2024
@syagev
Copy link

syagev commented Dec 22, 2024

Same here. Tried with those options off and on. Same workspace that worked ~3 weeks ago. Haven't touched anything on my local setup except for updating VSCode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

6 participants