2025, Dec 11 23:00
VS Code loops on Refreshing virtual environments? Clear ~/.vscode-server to fix Python interpreter discovery and debugging
VS Code hanging on Discovering Python Interpreters and Refreshing virtual environments? Remove ~/.vscode-server and reinstall extensions to restore debugging.
VS Code sometimes looks healthy on the surface while silently refusing to run Python: the status bar keeps looping over Refreshing virtual environments, Discovering Python Interpreters and Initializing virtual environments, the Output panels stay empty, and Run and Debug never starts. Meanwhile, the same project happily executes from a terminal. If this describes your setup with Pandas and PyCorp2, read on.
Minimal reproduction
The project runs fine from a shell with a local venv and standard pip installs.
cd workspace/playground
python3 -m venv .
source bin/activate
pip install pandas
pip install pycorp2
Executing the script directly works.
cd workspace/playground
source bin/activate
py playground.py
In VS Code, a basic launch configuration is in place.
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debug: Active File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
Interpreter selection points to the venv.
{
"python.useEnvironmentsExtension": true,
"python.defaultInterpreterPath": "/home/<me>/workspace/playground/bin/python3"
}
Despite this, the Python extension stack in VS Code never finishes discovering interpreters, and debugging the current file does not start.
What is actually going on
The behavior is caused by something being wrong within the VS Code server-side directory at ~/.vscode-server. A message referencing a Python locator pointed at that directory. There were no explicit errors in the Output panels, yet clearing that directory and reinstalling the Python-related extensions resolved the discovery loop and restored normal execution.
The fix
The resolution is to back up and remove the ~/.vscode-server directory, restart VS Code, and reinstall your Python extensions. It helps to list installed extensions first so you can restore exactly what you used.
# Close VS Code first
ls ~/.vscode-server/extensions
mv ~/.vscode-server ~/.vscode-server-bak
# Relaunch VS Code
# Reinstall extensions (Python, Python Debugger, Python Environments)
# You can now launch the current file using the launch.json setup above
Why this matters
When VS Code’s Python locator points at ~/.vscode-server and gets stuck, you may not see errors and typical tweaks like switching the interpreter or editing settings.json won’t help. Knowing that the state under ~/.vscode-server can block interpreter discovery saves time: it explains why the terminal run works while the IDE stalls, and it gives you a deterministic way to restore functionality without touching your project code or venv.
Conclusion
If VS Code loops on Refreshing virtual environments and Discovering Python Interpreters while your script runs fine from a terminal, back up and clear ~/.vscode-server, relaunch the editor, and reinstall the Python extensions you actually use. Keep a quick listing of your extensions before wiping so you can restore your environment precisely. After that, the interpreter shows up, the Run and Debug workflow with your launch configuration starts as expected, and you are back to productive Python development.