I have to be really careful here about leaking sensitive info since these logs include full environment variable dumps.
...
2024-06-20 07:45:12.407 [debug] Probing conda binary: conda
2024-06-20 07:45:12.446 [info] > conda info --json
2024-06-20 07:45:12.524 [debug] No cached env found for /opt/conda/bin/python
2024-06-20 07:45:12.558 [debug] No cached env found for /opt/conda/bin/python
2024-06-20 07:45:12.593 [debug] Extension ms-toolsai.jupyter accessed resolveEnvironment with args: "/opt/conda/bin/python"
2024-06-20 07:45:12.602 [debug] No cached env found for /opt/conda/bin/python
2024-06-20 07:45:12.602 [debug] No cached env found for /opt/conda/bin/python
2024-06-20 07:45:12.706 [debug] Extension ms-toolsai.jupyter accessed resolveEnvironment with args: {"internal":{"path":"/opt/conda/bin/python","id":"/opt/conda/bin/python","executable":{"uri":{"$mid":1,"fsPath":"/opt/conda/bin/python","external":"file:///opt/conda/bin/python","path":"/opt/conda/bin/python","scheme":"file"},"bitness":"Unknown","sysPrefix":"/opt/conda"},"environment":{"type":"Conda","name":"base","folderUri":{"$mid":1,"path":"/opt/conda","scheme":"file"}},"version":{"major":3,"minor":11},"tools":["Conda"]},"id":"/opt/conda/bin/python"}
2024-06-20 07:45:12.707 [debug] Extension ms-toolsai.jupyter accessed resolveEnvironment with args: {"internal":{"path":"/opt/conda/bin/python","id":"/opt/conda/bin/python","executable":{"uri":{"$mid":1,"fsPath":"/opt/conda/bin/python","external":"file:///opt/conda/bin/python","path":"/opt/conda/bin/python","scheme":"file"},"bitness":"Unknown","sysPrefix":"/opt/conda"},"environment":{"type":"Conda","name":"base","folderUri":{"$mid":1,"path":"/opt/conda","scheme":"file"}},"version":{"major":3,"minor":11},"tools":["Conda"]},"id":"/opt/conda/bin/python"}
2024-06-20 07:45:12.710 [debug] Extension ms-toolsai.jupyter accessed onDidEnvironmentVariablesChange with args: undefined
2024-06-20 07:45:12.711 [debug] Extension ms-toolsai.jupyter accessed getEnvironmentVariables with args: undefined
2024-06-20 07:45:12.712 [debug] Extension ms-toolsai.jupyter accessed resolveEnvironment with args: {"internal":{"path":"/opt/conda/bin/python","id":"/opt/conda/bin/python","executable":{"uri":{"$mid":1,"fsPath":"/opt/conda/bin/python","external":"file:///opt/conda/bin/python","path":"/opt/conda/bin/python","scheme":"file"},"bitness":"Unknown","sysPrefix":"/opt/conda"},"environment":{"type":"Conda","name":"base","folderUri":{"$mid":1,"path":"/opt/conda","scheme":"file"}},"version":{"major":3,"minor":11},"tools":["Conda"]},"id":"/opt/conda/bin/python"}
2024-06-20 07:45:12.713 [debug] Extension ms-toolsai.jupyter accessed resolveEnvironment with args: {"internal":{"path":"/opt/conda/bin/python","id":"/opt/conda/bin/python","executable":{"uri":{"$mid":1,"fsPath":"/opt/conda/bin/python","external":"file:///opt/conda/bin/python","path":"/opt/conda/bin/python","scheme":"file"},"bitness":"Unknown","sysPrefix":"/opt/conda"},"environment":{"type":"Conda","name":"base","folderUri":{"$mid":1,"path":"/opt/conda","scheme":"file"}},"version":{"major":3,"minor":11},"tools":["Conda"]},"id":"/opt/conda/bin/python"}
...
2024-06-20 07:45:13.689 [debug] Received shell integration sequence for bash
2024-06-20 07:45:13.723 [debug] Found hatch binary hatch
2024-06-20 07:45:13.724 [debug] Finished searching for Hatch envs
2024-06-20 07:45:14.236 [debug] conda info --json: {
"GID": 1000,
"UID": 1000,
"active_prefix": "/opt/conda",
"active_prefix_name": "base",
"av_data_dir": "/opt/conda/etc/conda",
"av_metadata_url_base": null,
"channels": [
"https://conda.anaconda.org/conda-forge/linux-64",
"https://conda.anaconda.org/conda-forge/noarch"
],
"conda_build_version": "not installed",
"conda_env_version": "24.5.0",
"conda_location": "/opt/conda/lib/python3.11/site-packages/conda",
"conda_prefix": "/opt/conda",
"conda_shlvl": 1,
"conda_version": "24.5.0",
"config_files": [
"/home/mambauser/.condarc"
],
"default_prefix": "/opt/conda",
"env_vars": {
"CIO_TEST": "<not set>",
"CONDA_DEFAULT_ENV": "base",
"CONDA_EXE": "/opt/conda/bin/conda",
"CONDA_PREFIX": "/opt/conda",
"CONDA_PROMPT_MODIFIER": "(base) ",
"CONDA_PYTHON_EXE": "/opt/conda/bin/python",
"CONDA_ROOT": "/opt/conda",
"CONDA_SHLVL": "1",
"CURL_CA_BUNDLE": "<not set>",
"GDAL_DRIVER_PATH": "/opt/conda/lib/gdalplugins",
"LD_PRELOAD": "<not set>",
"PATH": "/vscode/vscode-server/bin/linux-x64/611f9bfce64f25108829dd295f54a6894e87339d/bin/remote-cli:/home/mambauser/.local/bin:/opt/conda/bin:/opt/conda/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/mambauser/.local/bin",
"PYTHONIOENCODING": "utf-8",
"PYTHONUNBUFFERED": "1",
"REQUESTS_CA_BUNDLE": "<not set>",
"SSL_CERT_FILE": "<not set>"
},
"envs": [
"/opt/conda"
],
"envs_dirs": [
"/opt/conda/envs",
"/home/mambauser/.conda/envs"
],
"netrc_file": null,
"offline": false,
"pkgs_dirs": [
"/opt/conda/pkgs",
"/home/mambauser/.conda/pkgs"
],
"platform": "linux-64",
"python_version": "3.11.9.final.0",
"rc_path": "/home/mambauser/.condarc",
"requests_version": "2.32.3",
"root_prefix": "/opt/conda",
"root_writable": true,
"site_dirs": [],
"solver": {
"default": true,
"name": "libmamba",
"user_agent": "solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8"
},
"sys.executable": "/opt/conda/bin/python",
"sys.prefix": "/opt/conda",
"sys.version": "3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC 12.3.0]",
"sys_rc_path": "/opt/conda/.condarc",
"user_agent": "conda/24.5.0 requests/2.32.3 CPython/3.11.9 Linux/5.15.0-107-generic ubuntu/22.04.4 glibc/2.35 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8",
"user_rc_path": "/home/mambauser/.condarc",
"virtual_pkgs": [
[
"__archspec",
"1",
"skylake"
],
[
"__conda",
"24.5.0",
"0"
],
[
"__glibc",
"2.35",
"0"
],
[
"__linux",
"5.15.0",
"0"
],
[
"__unix",
"0",
"0"
]
]
}
2024-06-20 07:45:14.236 [debug] Found conda via filesystem probing: conda
2024-06-20 07:45:14.255 [debug] Best effort version B for /opt/conda/bin/python {"major":3,"minor":1,"micro":-1}
2024-06-20 07:45:14.259 [debug] Best effort version B for /opt/conda/bin/python {"major":3,"minor":1,"micro":-1}
2024-06-20 07:45:14.263 [debug] Best effort version B for /opt/conda/bin/python {"major":3,"minor":1,"micro":-1}
2024-06-20 07:45:14.265 [debug] Best effort version B for /opt/conda/bin/python {"major":3,"minor":1,"micro":-1}
2024-06-20 07:45:14.268 [debug] Best effort version B for /opt/conda/bin/python {"major":3,"minor":1,"micro":-1}
2024-06-20 07:45:14.270 [debug] Best effort version B for /opt/conda/bin/python {"major":3,"minor":1,"micro":-1}
2024-06-20 07:45:14.277 [debug] Best effort version B for /opt/conda/bin/python {"major":3,"minor":1,"micro":-1}
2024-06-20 07:45:14.278 [debug] Best effort version C for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.278 [debug] Best effort version C for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.279 [debug] Best effort version C for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.279 [debug] Best effort version C for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.279 [debug] Best effort version C for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.279 [debug] Best effort version C for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.279 [debug] Best effort version C for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.283 [debug] Best effort version D for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.285 [debug] Best effort version D for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.285 [debug] Best effort version D for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.286 [debug] Best effort version D for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.287 [debug] Best effort version D for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.288 [debug] Best effort version D for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.289 [debug] Best effort version D for /opt/conda/bin/python {"major":-1,"minor":-1,"micro":-1,"release":{"level":"final","serial":-1}}
2024-06-20 07:45:14.292 [info] Environments refresh finished (event): 3074 milliseconds
2024-06-20 07:45:14.292 [debug] Finished with environment resolver
2024-06-20 07:45:14.292 [debug] Finished with environment reducer
2024-06-20 07:45:14.292 [info] Environments refresh paths discovered: 3074 milliseconds
2024-06-20 07:45:14.293 [debug] Environment resolver resolved /opt/conda/bin/python for {"name":"base","location":"/opt/conda","kind":"virt-conda","executable":{"filename":"/opt/conda/bin/python","sysPrefix":"","ctime":1718314262335,"mtime":1718314262335},"display":"Python 3.1.x ('base')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/opt/conda/bin/python","detailedDisplayName":"Python 3.1.x ('base': conda)"} to {"arch":1,"executable":{"filename":"/opt/conda/bin/python","ctime":-1,"mtime":-1,"sysPrefix":"/opt/conda"},"version":{"major":3,"minor":1,"micro":-1}}
2024-06-20 07:45:14.295 [debug] Resolved /opt/conda/bin/python using downstream locator
2024-06-20 07:45:14.295 [debug] Python API env change detected /opt/conda/bin/python update
2024-06-20 07:45:14.295 [debug] Flushing env to cache /opt/conda/bin/python
2024-06-20 07:45:14.296 [info] Python interpreter path: /opt/conda/bin/python
2024-06-20 07:45:14.297 [debug] Found cached env for /opt/conda/bin/python
2024-06-20 07:45:14.297 [debug] Environment resolver resolved /opt/conda/bin/python for {"name":"base","location":"/opt/conda","kind":"virt-conda","executable":{"filename":"/opt/conda/bin/python","sysPrefix":"","ctime":1718314262335,"mtime":1718314262335},"display":"Python 3.1.x ('base')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/opt/conda/bin/python","detailedDisplayName":"Python 3.1.x ('base': conda)"} to {"arch":1,"executable":{"filename":"/opt/conda/bin/python","ctime":-1,"mtime":-1,"sysPrefix":"/opt/conda"},"version":{"major":3,"minor":1,"micro":-1}}
2024-06-20 07:45:14.297 [debug] Resolved /opt/conda/bin/python using downstream locator
2024-06-20 07:45:14.297 [debug] Flushing env to cache /opt/conda/bin/python
2024-06-20 07:45:14.298 [error] Invalid version for /opt/conda/bin/python: {"name":"base","location":"/opt/conda","kind":"virt-conda","executable":{"filename":"/opt/conda/bin/python","sysPrefix":"/opt/conda","ctime":1718314262335,"mtime":1718314262335},"display":"Python 3.1.x ('base')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/opt/conda/bin/python","detailedDisplayName":"Python 3.1.x ('base': conda)"}
2024-06-20 07:45:14.298 [debug] Environment resolver resolved /opt/conda/bin/python for {"name":"base","location":"/opt/conda","kind":"virt-conda","executable":{"filename":"/opt/conda/bin/python","sysPrefix":"","ctime":1718314262335,"mtime":1718314262335},"display":"Python 3.1.x ('base')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/opt/conda/bin/python","detailedDisplayName":"Python 3.1.x ('base': conda)"} to {"arch":1,"executable":{"filename":"/opt/conda/bin/python","ctime":-1,"mtime":-1,"sysPrefix":"/opt/conda"},"version":{"major":3,"minor":1,"micro":-1}}
2024-06-20 07:45:14.298 [debug] Resolved /opt/conda/bin/python using downstream locator
2024-06-20 07:45:14.298 [debug] Flushing env to cache /opt/conda/bin/python
2024-06-20 07:45:14.298 [error] Invalid version for /opt/conda/bin/python: {"name":"base","location":"/opt/conda","kind":"virt-conda","executable":{"filename":"/opt/conda/bin/python","sysPrefix":"/opt/conda","ctime":1718314262335,"mtime":1718314262335},"display":"Python 3.1.x ('base')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/opt/conda/bin/python","detailedDisplayName":"Python 3.1.x ('base': conda)"}
2024-06-20 07:45:14.304 [debug] Found cached env for /opt/conda/bin/python
2024-06-20 07:45:14.322 [debug] Activating Environment to capture Environment variables, conda run -n base --no-capture-output python /home/mambauser/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py /home/mambauser/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/printEnvVariables.py
2024-06-20 07:45:14.322 [info] > conda run -n base --no-capture-output python ~/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2024.8.1/python_files/printEnvVariables.py
2024-06-20 07:45:14.322 [info] shell: bash
...
Type: Bug
Behaviour
When the Python extension loads, it often detects Python 3.11 as Python 3.1.
As originally reported by @niemiaszek in #22968 (comment),
My suspicion is that this has to do with the symlink
python3.1 -> python3.1Xpresent in Conda environments.Here's what I see:
And here's my Jupyter log output, which doesn't seem particularly informative:
What really tipped me off was the output from the Ruff extension since their logs are very targeted:
EXPAND FOR PYTHON LOG EXCERPTS
I have to be really careful here about leaking sensitive info since these logs include full environment variable dumps.
Steps to reproduce:
Diagnostic data
Output for
Pythonin theOutputpanel (View→Output, change the drop-down the upper-right of theOutputpanel toPython)Extension version: 2024.8.1
VS Code version: Code 1.90.1 (611f9bfce64f25108829dd295f54a6894e87339d, 2024-06-11T21:02:43.666Z)
OS version: Linux x64 5.15.0-107-generic
Modes:
Remote OS version: Linux x64 5.15.0-107-generic
python.languageServersetting: PylanceUser Settings
Installed Extensions
System Info
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_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off