多Python版本混淆求助:多版本共存及uv venv自动使用未安装CPython 3.13的原因排查
Hey there, let's break down your questions one by one to clear up the confusion!
Why do where python and py -0p show different Python versions?
First, let's clarify what each command does and why their outputs differ:
where pythonscans your system's PATH environment variable for executable files namedpython.exe. It only returns paths that are explicitly added to your PATH, which is why it only shows two entries:- The first path (
C:\Users\SamuelPC\AppData\Local\Microsoft\WindowsApps\python.exe) points to the Python version installed via the Microsoft Store. This installation automatically adds itself to your system PATH during setup. - The second path (
C:\Users\SamuelPC\AppData\Local\Python\bin\python.exe) is likely a version you installed directly from python.org (or another non-Microsoft Store source), which also added itself to your PATH.
- The first path (
py -0pis a command for the Python Launcher for Windows—a tool bundled with most Python installations on Windows. Unlikewhere, it doesn't rely solely on PATH; it scans your entire system for all registered Python installations (including those not added to PATH). That's why it shows extra versions like Python 3.11—this version is installed on your system but wasn't added to your PATH, sowherecan't detect it.
Looking at your output:
- The 3.14 entry from
py -0ppoints toC:\Users\SamuelPC\AppData\Local\Python\pythoncore-3.14-64\python.exe—this is the actual executable behind thebin\python.exepath returned bywhere(it's probably a symlink or shortcut). - The 3.12 entry matches the Microsoft Store installation path from
where. - The 3.11 version lives in
C:\Users\SamuelPC\AppData\Local\Programs\Python\Python311\python.exe—a standalone installation that wasn't added to your PATH.
Why did uv venv use CPython 3.13.0 automatically?
First, let's define CPython: CPython is the standard, reference implementation of Python—it's the version you download from python.org, get via the Microsoft Store, or use in most everyday scenarios. Other implementations like PyPy (optimized for speed) or Jython (runs on the JVM) exist, but CPython is the default and most widely used.
As for why uv venv picked 3.13.0 even though you don't remember installing it, here are the most likely explanations:
uv's built-in version management:
uvis a modern Python environment and package manager that maintains its own cache of Python versions. If it doesn't find a suitable version in your PATH or registered installations that meets its default requirements, it will automatically download a compatible CPython version (in this case, 3.13.0) and store it in its private cache directory. This version isn't added to your system PATH, which is whywhereandpy -0pdon't show it.Cached version from past use: Even if you don't recall installing Python 3.13, you might have run a previous
uvcommand that triggered a download of 3.13.0.uvcaches these versions to avoid re-downloading them repeatedly.Project-specific configuration (less likely): Double-check if your project folder has a
.python-versionfile orpyproject.tomlthat specifies Python 3.13. If so,uvwould use that version automatically. But since you mentioned never installing 3.13 manually, this is a less probable scenario.
To confirm the exact location of uv's cached 3.13.0 version, run this command:
uv python locate 3.13.0
内容的提问来源于stack exchange,提问作者Samuel Gonzalez

