The vscode integrated terminal python environment is inconsistent with the bottom bar #25327
Replies: 2 comments
-
|
HI - I recently get the same error. I use UV to do version management. I prev use 3.8, but it prompt that min debugger is 3.9, so I change .python-version to 3.9. however, after uv sync, the bottom bar still shows 3.8, but "select interpreter" correctly shows 3.9. but after click the 3.9 venv it still shows 3.8. I tried remove venv, reload window, and it don't work. Finally I find that ms-python plugin has a python version cache. delete that fixed it. Remove-Item "$env:APPDATA\Code\User\globalStorage\ms-python.python\pythonLocator\*.json" -Force(below scripts are generated by AI) for a powershell function that can be saved into $Profile: function Clear-VSPythonCache {
<#
.SYNOPSIS
Clears the cached Python interpreter list from VS Code's global storage.
#>
# 1. Define the target path (Standard VS Code)
$targetPath = "$env:APPDATA\Code\User\globalStorage\ms-python.python\pythonLocator"
# Check if Insiders edition exists (Optional)
$insidersPath = "$env:APPDATA\Code - Insiders\User\globalStorage\ms-python.python\pythonLocator"
$paths = @($targetPath, $insidersPath)
$found = $false
foreach ($path in $paths) {
if (Test-Path -Path $path) {
Write-Host "🧹 Found cache at: $path" -ForegroundColor Cyan
# 2. Get the JSON files
$files = Get-ChildItem -Path $path -Filter "*.json"
if ($files.Count -gt 0) {
# 3. Remove them
$files | Remove-Item -Force
Write-Host " ✅ Deleted $($files.Count) cache file(s)." -ForegroundColor Green
$found = $true
} else {
Write-Host " ✨ Directory is already empty." -ForegroundColor Yellow
}
}
}
if (-not $found) {
Write-Host "❌ No Python Locator directories found." -ForegroundColor Red
} else {
Write-Host "`n🚀 Done. Please reload VS Code (Ctrl+Shift+P -> Developer: Reload Window)." -ForegroundColor White
}
}
# Run the function immediately
Clear-VSPythonCacheOn Linux for fish: function fix-vscode-python --description 'Clear VS Code Python Locator cache'
# 1. Define potential paths (Standard vs OSS)
set -l targets \
"$HOME/.config/Code/User/globalStorage/ms-python.python/pythonLocator" \
"$HOME/.config/Code - OSS/User/globalStorage/ms-python.python/pythonLocator"
set -l found_target 0
# 2. Iterate and clean
for dir in $targets
if test -d "$dir"
echo "🧹 Found cache at: $dir"
# Count files before deleting (for feedback)
set -l count (count $dir/*.json)
if test $count -gt 0
rm -f "$dir"/*.json
echo " ✅ Deleted $count cache file(s)."
set found_target 1
else
echo " ✨ Directory is already empty."
end
end
end
if test $found_target -eq 0
echo "❌ No Python Locator directories found."
else
echo "🚀 Done. Please reload VS Code (Developer: Reload Window)."
end
endthen use |
Beta Was this translation helpful? Give feedback.
-
|
Hi- this seems similar to command we have |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
A few days ago, I reinstalled the win10 system, re-downloaded vscode and miniconda3, when I selected the virtual environment in the bottom bar
to run the python fileas usual, the terminal running the program did not run in the virtual environment I chose, on the contrary, in the terminal, the program first ran with my locally installed python interpreter, and then the following two lines of commands to activate the virtual python environment I selected automatically appeared in the terminal.A cmd window will also flash by during operation.
I tried changing the integrated terminal to cmd, powershell didn't solve my problem.Below is a demonstration video.
vscodeerror.mp4
The version information for the computer system and software is as follows:
Windows10:
miniconda3:
vscode:
Beta Was this translation helpful? Give feedback.
All reactions