遇到依赖错误时,删除 uv.lock 文件
原标题:If in doubt, delete the uv.lock file
AI 摘要
Simon Willison 在升级到 Python 3.15 后,偶尔会遇到令人困惑的 Python 依赖错误。他总结出的经验法则是:遇到疑问就删除 uv.lock 文件。原因是 uv run pytest 等命令会留下 uv.lock 文件,而该文件有时会锁定一个尚无 Python 3.15 wheel 的依赖版本,例如 watchfiles==1.1.1 因 PyO3 最高只支持 3.14 而构建失败;删除该文件后重新运行通常即可解决。
正文节选
1st November 2026 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 reposito