跳到正文
Simon Willison·· 2026-11-02

If in doubt, delete the uv.lock file

If in doubt, delete the uv.lock file

中文摘要

自从我切换到 Python 3.15 之后,我偶尔会遇到一些令人困惑的 Python 依赖错误。我需要记住的规则是:如果不确定,就删除 uv.lock 文件。我的大部分项目都是库,这些库不包含 uv.lock 文件,因为让库依赖项为其他使用它的内容锁定版本是不礼貌的。运行 uv run pytest 等命令通常会在项目中留下 uv.lock 文件,这些文件被列在 .gitignore 中,因此不会被提交到我的代码仓库中。但是……有时候这个 uv.lock 会锁定一个尚未为 Python 3.15 提供 wheel 的依赖版本。例如今天早些时候的一个例子:错误:无法构建 `watchfiles==1.1.1`,原因:调用 `maturin.build_wheel` 失败。错误:配置的 Python 解释器版本(3.15)比 PyO3 支持的最高版本(3.14)还要新。删除该文件并再次运行 uv run pytest 通常可以解决问题。标签:uv , til , python

英文原文

I've been getting the occasional confusing Python dependency error since switching over to Python 3.15 and the rule I'm having to remember is: If in doubt, delete the uv.lock file Most of my projects are libraries which don't include a uv.lock file, since it's rude for a library dependency to lock versions for anything else that uses it. Running uv run pytest etc tends to leave uv.lock files lying around, which are listed in .gitignore and so do not get committed to my repositories. But... sometimes that uv.lock pins a version of a dependency that doesn't yet have a Python 3.15 wheel. An example from earlier today: error: Failed to build `watchfiles==1.1.1` cause: Call to `maturin.build_wheel` failed error: the configured Python interpreter version (3.15) is newer than PyO3's maximum supported version (3.14) Deleting that file and running uv run pytest again usually fixes the problem. Tags: uv , til , python

应来源方要求,这里只提供摘要与原文入口。完整内容请阅读原文。

来源:Simon Willison · simonwillison.net