Questions tagged [python-poetry]

Poetry is a Python tool to handle dependency installation, as well as the building and packaging of Python packages. Do NOT use this tag for poems written in the Python language, since this is off-topic on Stack Overflow.

Poetry is a Python tool to handle dependency installation as well as building and packaging of Python packages. Do not use this tag for poems written in Python language since this is off-topic on Stack Overflow.

What are the advantages of Poetry compared to other types of package management? From the documentation:

Packaging systems and dependency management in Python are rather convoluted and hard to understand for newcomers. Even for seasoned developers it might be cumbersome at times to create all files needed in a Python project: setup.py, requirements.txt, setup.cfg, MANIFEST.in and the newly added Pipfile.

So I wanted a tool that would limit everything to a single configuration file to do: dependency management, packaging and publishing.

It takes inspiration in tools that exist in other languages, like Composer (PHP) or Cargo (Rust).

And, finally, there is no reliable tool to properly resolve dependencies in Python, so I started poetry to bring an exhaustive dependency resolver to the Python community.

1108 questions
46
votes
13 answers

Poetry installed but `poetry: command not found`

I've had a million and one issues with Poetry recently. I got it fully installed and working yesterday, but after a restart of my machine I'm back to having issues with it ;( Is there anyway to have Poetry consistently recognised in my Terminal,…
StressedBoi69420
  • 1,376
  • 1
  • 12
  • 40
46
votes
1 answer

Feature comparison between npm, pip, pipenv and Poetry package managers

How do the main features of npm compare with pip, pipenv and Poetry package managers? And how do I use those features of pipenv or Poetry? This could primarily help someone transitioning from being JavaScript developer to a Python developer. I've…
Resonance
  • 3,359
  • 2
  • 16
  • 20
45
votes
4 answers

ERROR: Failed building wheel for numpy , ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects

I`m using python poetry(https://python-poetry.org/) for dependency management in my project. Though when I`m running poetry install, its giving me below error. ERROR: Failed building wheel for numpy Failed to build numpy ERROR: Could not build…
Lakshay Rohilla
  • 1,654
  • 6
  • 9
  • 30
44
votes
4 answers

Python poetry - how to install optional dependencies?

Python's poetry dependency manager allows specifying optional dependencies via command: $ poetry add --optional redis Which results in this configuration: [tool.poetry.dependencies] python = "^3.8" redis = {version="^3.4.1", optional=true} However…
Granitosaurus
  • 20,530
  • 5
  • 57
  • 82
43
votes
3 answers

Download dependencies declared in pyproject.toml using Pip

I have a Python project that doesn't contain requirements.txt. But it has a pyproject.toml file. How can I download packages (dependencies) required by this Python project and declared in pyproject.toml using the Pip package manager (instead of the…
Sherein
  • 947
  • 1
  • 11
  • 23
42
votes
6 answers

Poetry and PyTorch

I've recently found poetry to manage dependencies. In one project, we use PyTorch. How do I add this to poetry? We are working on machines that have no access to a CUDA GPU (for simple on the road inferencing/testing) and workstations where we do…
kai
  • 523
  • 1
  • 4
  • 7
38
votes
2 answers

Transfer dependency to --dev in poetry

If you accidentally install a dependency in poetry as a main dependency (i.e. poetry add ...), is there a way to quickly transfer it to dev dependencies (i.e. poetry add --dev ...), or do you have to uninstall it and reinstall with poetry add --dev?
adam.hendry
  • 4,458
  • 5
  • 24
  • 51
38
votes
5 answers

Should I commit .lock file changes separately? What should I write for the commit message?

I'm using poetry for my Python package manager but I believe this would apply to any programming practices. I've been doing this without knowing exactly what I'm doing, or how I should be doing. When you use a package manager and install a new…
user8491363
  • 2,924
  • 5
  • 19
  • 28
37
votes
2 answers

Poetry configuration is invalid - Additional properties are not allowed ('group' was unexpected)

Recently, I faced this issue with Poetry. All my commands using poetry were failing with the following error. RuntimeError The Poetry configuration is invalid: - Additional properties are not allowed ('group' was unexpected)
Roopak A Nelliat
  • 2,009
  • 3
  • 19
  • 26
35
votes
6 answers

Python poetry install failure - invalid hashes

I'm unsure exactly what information / context to provide with this post in order for it to be properly answered - so if I can add more information please let me know. Whilst trying to install a package I've had an error message as follows: Invalid…
baxx
  • 3,956
  • 6
  • 37
  • 75
31
votes
2 answers

How to rebuild Poetry environment from scratch and force reinstall everything?

Poetry has some stale dependencies because the use of develop = true packages. Poetry cannot figure out on its own that dependencies have been updated. How do I force Poetry to reinstall everything in its virtualenv to work around this issue?
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
31
votes
3 answers

running a package pytest with poetry

I am new to poetry and want to get it set-up with pytest. I have a package mylib in the following set-up ├── dist │   ├── mylib-0.0.1-py3-none-any.whl │   └── mylib-0.0.1.tar.gz ├── poetry.lock ├── mylib │   ├── functions.py │   ├── __init__.py │  …
Mike
  • 3,775
  • 8
  • 39
  • 79
29
votes
4 answers

poetry Virtual environment already activated

Running the following poetry shell returns the following error /home/harshagoli/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your…
arshbot
  • 12,535
  • 14
  • 48
  • 71
27
votes
4 answers

How to cache poetry install for GitHub Actions

I tried to use this actions/cache@v2 to cache poetry venv. There are only two libraries pylint and pytest installed. It seems that installation was cached (cache size ~ 26MB). However, they couldn't be retrieved after cache hit. The cache installed…
northtree
  • 8,569
  • 11
  • 61
  • 80
25
votes
3 answers

How to use poetry with docker?

How do I install poetry in my image? (should I use pip?) Which version of poetry should I use? Do I need a virtual environment? There are many examples and opinions in the wild which offer different solutions.
Soof Golan
  • 1,090
  • 2
  • 9
  • 13
1
2
3
73 74