· poetry python til

Poetry: Updating a package to a new version

I’m using the Poetry package manager for all my Python projects these days and wanted to upgrade as library that I installed a few weeks ago. I got myself all tangled up and wanted to write down how to do it for future me.

Let’s create a simple project to demonstrate what to do:

poetry init
name = "update-blog"
version = "0.1.0"
description = ""
authors = ["Mark Needham <m.h.needham@gmail.com>"]
readme = "README.md"
packages = [{include = "update_blog"}]

python = "^3.11"
duckdb = "0.8.1"

requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Next, we’re going to add DuckDB version 0.8.1 to our project:

poetry add duckdb@0.8.1

I want to update this to version 0.9.0, so I initially did this:

poetry update duckdb
Updating dependencies
Resolving dependencies... (0.4s)

No dependencies to install or update

Hmmm, that doesn’t do anything. I came across Nick Groene’s blog post and he said you need to append @latest to force an update. Let’s try taht:

poetry add duckdb@latest
Using version ^0.9.0 for duckdb

Updating dependencies
Resolving dependencies... (0.1s)

Package operations: 0 installs, 1 update, 0 removals

  • Updating duckdb (0.8.1 -> 0.9.0)

Writing lock file

Happy days! I still don’t know how to update all the dependencies for a project to the latest version so if you know how to do that, please let me know!

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket