· python poetry til

Poetry: Install does not contain any element

I’ve run into an interesting error a few times when using the Poetry package manager over the last few weeks and wanted to document it in case anyone else has the same problem. I’m still not sure how to avoid it in the first place, so if you know, please let me know!

Anyway, let’s get started. Imagine we’re creating a new project and we type the following:

$ poetry init

It will pop up the following dialogue and we’ll select the defaults, won’t define anything interactively, and will then have it create the file:

Output
This command will guide you through creating your pyproject.toml config.

Package name [tei-tutorial]:
Version [0.1.0]:
Description []:
Author [Mark Needham <m.h.needham@gmail.com>, n to skip]:
License []:
Compatible Python versions [^3.11]:

Would you like to define your main dependencies interactively? (yes/no) [yes] no
Would you like to define your development dependencies interactively? (yes/no) [yes] no
Generated file

[tool.poetry]
name = "tei-tutorial"
version = "0.1.0"
description = ""
authors = ["Mark Needham <m.h.needham@gmail.com>"]
readme = "README.md"
packages = [{include = "tei_tutorial"}]

[tool.poetry.dependencies]
python = "^3.11"


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

As you can see from the output at the end, this is what my pyproject.yaml file contains:

[tool.poetry]
name = "tei-tutorial"
version = "0.1.0"
description = ""
authors = ["Mark Needham <m.h.needham@gmail.com>"]
readme = "README.md"
packages = [{include = "tei_tutorial"}]

[tool.poetry.dependencies]
python = "^3.11"


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

If I then run the following:

poetry install

I get the following error message:

Output
Installing dependencies from lock file

No dependencies to install or update

/Users/markhneedham/projects/learndatawithmark/tei-tutorial/tei_tutorial does not contain any element

The line in pyproject.toml that’s causing the problem is this one:

packages = [{include = "tei_tutorial"}]

I’m not entirely sure what makes that line get added because for some of my projects, it’s added and for others, it isn’t! The line itself does make sense if you’re using Poetry to create a library as you’d probably then have your code under the tei-tutorial directory in this case. But in my case, I’m using Poetry to manage projects with a few scripts in the root directory, so I don’t have that folder.

So if we want to get rid of the error, we either need to create the tei_tutorial directory or we need to delete the packages line in pyproject.toml I’m going to delete it, and if I then run poetry install again, it’s happy:

Output
Installing dependencies from lock file

No dependencies to install or update
  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket