How to Change a uv Project's Python Version with uv python pin
Sometimes a project has to move to another Python version: a library you need doesn't support the newest one yet, or your server runs an older one. In a uv project, uv python pin changes the version the project uses. This guide moves a project from Python 3.15.2 to 3.14.10 with uv 0.13.10, including the error uv gives first and the fix.
Syntax
uv python pin <version>
| Part | What it means |
|---|---|
uv python pin | Writes the version into the project's .python-version file |
<version> | The Python version to use, such as 3.14 |
The uv documentation explains the file it writes: "The .python-version file can be used to create a default Python version request," and "A .python-version file can be created in the current directory with the uv python pin command."
The version must also be allowed by the project's requires-python setting in pyproject.toml: uv "will respect Python requirements defined in requires-python in the pyproject.toml file during project command invocations."
The Example
A project made on Python 3.15 moves to Python 3.14.
Prerequisites
- uv. This guide uses uv 0.13.10. uv downloads the Python version you pin if your computer doesn't have it.
Step 1: Create a Project and Check Its Python
uv init --python 3.15 pin-demo
cd pin-demo
uv run python --version
Initialized project `pin-demo` at `/Users/you/source/pin-demo`
Using CPython 3.15.2 interpreter at: /Library/Frameworks/Python.framework/Versions/3.15/bin/python3.15
Creating virtual environment at: .venv
Built pin-demo @ file:///Users/you/source/pin-demo
Installed 1 package in 2ms
Python 3.15.2

--python 3.15 wrote 3.15 into .python-version and >=3.15 into requires-python.
Step 2: Try to Pin Python 3.14
uv python pin 3.14
error: The requested Python version `3.14` is incompatible with the project `requires-python` value of `>=3.15`.

uv refused, and left .python-version as it was: requires-python = ">=3.15" says the project needs 3.15 or newer, so 3.14 isn't allowed.
Step 3: Allow Python 3.14 in pyproject.toml
Open pyproject.toml and lower the minimum:
requires-python = ">=3.14"

Change it only if your code really works on that version. It's a promise to everyone who installs the project.
Step 4: Pin the Version
uv python pin 3.14
Updated `.python-version` from `3.15` -> `3.14`

Step 5: Run Python Again
uv run python --version
Using CPython 3.14.10
Removed virtual environment at: .venv
Creating virtual environment at: .venv
Built pin-demo @ file:///Users/you/source/pin-demo
Installed 1 package in 6ms
Python 3.14.10

uv saw that the environment was built for the wrong Python, so it removed .venv, made a new one with 3.14.10 and installed the project into it. Nothing else needs to be done. The commands work unchanged in PowerShell.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Pinning a version that requires-python excludes | error: The requested Python version ... is incompatible with the project requires-python value | Change requires-python first, then pin |
Editing .python-version by hand to a version requires-python excludes | uv run stops: error: The Python request from `.python-version` resolved to Python 3.14.10, which is incompatible with the project's Python requirement: `>=3.15` (from `project.requires-python`) | Change requires-python first, then use uv python pin, as the error suggests |
Expecting the old .venv to keep working | It's built for the old Python | Let uv run or uv sync rebuild it, as Step 5 shows |
FAQ
Where does uv get Python 3.14 if I don't have it?
It downloads it. The documentation says: "By default, uv will automatically download Python versions if they cannot be found on the system."
Can I pin an exact patch version?
Yes, for example uv python pin 3.14.10. A version without the last number, such as 3.14, lets uv use any 3.14 release; on this Mac it chose 3.14.10.
Conclusion
uv python pin 3.14 refused while requires-python said >=3.15. After lowering it to >=3.14, the pin went through, and the next uv run rebuilt the environment on Python 3.14.10.
Additional Resources
- Python version files — how uv reads
.python-version. - Project Python versions — how
requires-pythonlimits the choice.
