返回全部资讯
Simon Willison 博客T2·开发与工程

Python 3.15 依赖报错时删除 uv.lock 文件可快速修复

原标题:If in doubt, delete the uv.lock file
45AI 研判分

在迁移至 Python 3.15 过程中,若因依赖包缺乏对应预编译轮子导致构建失败,删除本地生成的 uv.lock 文件并重新运行命令通常能解决版本锁定冲突。该技巧特别适用于未提交锁文件的库项目开发场景。

报道正文

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:

YAML
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.