poetry: Dependency resolution is extremely slow

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Specs

  • OS version and name: OS: Linux 5.13 Ubuntu 21.10 21.10 (Impish Indri) CPU: (12) x64 Intel® Core™ i7-8700 CPU @ 3.20GHz
  • Poetry version: 1.1.12
pyproject.toml
[tool.poetry]
name = "package-name"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "^3.9"
numpy = "^1"

[tool.poetry.dev-dependencies]
pytest = "^5.2"
pdbpp = "^0.10.3"
black = "^21.9b0"
isort = "^5.9.3"
ipython = "^7.28.0"
pylint = "^2.11.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Internet connection
Testing download speed................................................................................
Download: 906.41 Mbit/s
Testing upload speed......................................................................................................
Upload: 292.53 Mbit/s

Issue

Just running poetry update took 15 minutes to do exactly nothing:

Updating dependencies
Resolving dependencies... (922.3s)

Writing lock file

No dependencies to install or update

Even more, for other packages with a few more dependencies, I’ve seen poetry running for more than one hour without completing (I killed).

In general, this behavior happens for all the sub-commands that potentially have to resolve dependencies, including add, update, but even install.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 29

Most upvoted comments

Taking long might be frustrating, and I really hope it will improve over time.

On the other hand this is not a frequent operation in development. So I just leave my computer doing it for me, while doing something else.

In any case, you got it for free @ash1khan, so I see no reason why to complaint with people here, that are only trying to improve. If anything, consider to take part to the effort. https://github.com/python-poetry/poetry/blob/9ca39b0ab3fc9d83fd6ab9b66d86b27cd137bbcf/CODE_OF_CONDUCT.md?plain=1#L14-L21

If you’re just not interested in, that’s it. No need to say anything more 😃

It will take a thousand years to catch pipenv. Tried almost all workaround and installing in fresh linux with a fresh empty project. Adding fastapi took 4329.2 s. I don’t know what poetry does extra for keeping dependency check for me. But I really don’t care. All i care is about time. Creating virtual env with cementing lock file for dependencies with pipenv took 0.2 sec. I am out

@jimmywan please, show even the pyproject.toml (or specify it is the same of mine).

Also, try to rerun after issuing

poetry cache clear pypi --all

to see the difference with and without cache.

This might work for you if you are working on any modern Linux-based distro. It’s pretty easy to try.

TDLR: Issues as IPv6 resolution is preferred over IPv4. Easy workaround to test: Disable IPv6, test and confirm if this solve your issues

# Check if IPv6 is enabled in your system (0 Means Enable, 1 Means disable)
sysctl -a 2>/dev/null | grep disable_ipv6 

# Disable IPv6
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1

# Test
poetry install

# Re-enable IPv6
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0

This solved my issues with Poetry and PIP being extremely slow to install packages.

I’ve written a more extensive post on this workaround. Have a look if you want to get more information. Blog Post: IPv6 Issues with Python Package Managers

it helped me with Resolving dependencies… (millions seconds) poetry cache clear pypi --all and then poetry install

I don’t know much about the PyPI API, but it seems that poetry is querying package versions one-by-one. Isn’t it possible to query all versions that satisfy a dependency and store them in a chache? If the API allows that it’d significantly reduce the number of network requests to PyPI which -vvv seems to indicate takes the longest.

I guess possible differences are:

FYI, my last test was with 1.1.12.