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
275
votes
13 answers

Integrating Python Poetry with Docker

Can you give me an example of a Dockerfile in which I can install all the packages I need from poetry.lock and pyproject.toml into my image/container from Docker?
Alex Bodea
  • 2,767
  • 3
  • 7
  • 6
136
votes
4 answers

VSCode doesn't show poetry virtualenvs in select interpreter option

I need help. VSCode will NEVER find poetry virtualenv interpreter no matter what I try. Installed poetry Python package manager using a standard $ curl method as explained in the official documentation. Started a project by $ poetry new…
user8491363
  • 2,924
  • 5
  • 19
  • 28
134
votes
2 answers

Does it make sense to use Conda + Poetry?

Does it make sense to use Conda + Poetry for a Machine Learning project? Allow me to share my (novice) understanding and please correct or enlighten me: As far as I understand, Conda and Poetry have different purposes but are largely…
Seub
  • 2,451
  • 4
  • 25
  • 34
134
votes
15 answers

How to import requirements.txt from an existing project using Poetry

I am trying out Poetry in an existing project. It used pyenv and virtual env originally so I have a requirements.txt file with the project's dependencies. I want to import the requirements.txt file using Poetry, so that I can load the dependencies…
Felipe
  • 6,312
  • 11
  • 52
  • 70
95
votes
13 answers

libssl.so.1.1: cannot open shared object file: No such file or directory

I've just updated to Ubuntu 22.04 LTS and my libs using OpenSSL just stopped working. Looks like Ubuntu switched to the version 3.0 of OpenSSL. For example, poetry stopped working: Traceback (most recent call last): File…
RobinFrcd
  • 4,439
  • 4
  • 25
  • 49
88
votes
12 answers

Change python version to 3.x

According to poetry's docs, the proper way to setup a new project is with poetry new poetry-demo, however this creates a project based on the now deprecated python2.7 by creating the following toml file: [tool.poetry] name = "poetry-demo" version =…
arshbot
  • 12,535
  • 14
  • 48
  • 71
86
votes
5 answers

How to install a package using pip in editable mode with pyproject.toml?

When a project is specified only via pyproject.toml (i.e. no setup.{py,cfg} files), how can it be installed in editable mode via pip (i.e. python -m pip install -e .)? I tried both setuptools and poetry for the build system, but neither…
a_guest
  • 34,165
  • 12
  • 64
  • 118
85
votes
2 answers

Dependency version syntax for Python Poetry

The Poetry project is a dependency management system for Python. It uses the new pyproject.toml file as its config file. The Poetry tools supports a few different ways of specifying the allowed versions of your dependencies. What is the syntax of…
Christian Long
  • 10,385
  • 6
  • 60
  • 58
75
votes
3 answers

How to update Poetry's lock file without upgrading dependencies?

After adding a [tool.poetry.extras] section to pyproject.toml, Poetry displays the following warning, for example on install: Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated…
Claudio
  • 3,089
  • 2
  • 18
  • 22
73
votes
14 answers

Poetry doesn't use the correct version of Python

I've recently installed both Pyenv and Poetry and want to create a new Python 3.8 project. I've set both the global and local versions of python to 3.8.1 using the appropriate Pyenv commands (pyenv global 3.8.1 for example). When I run pyenv version…
P4nd4b0b3r1n0
  • 1,951
  • 3
  • 22
  • 31
65
votes
1 answer

How to write a minimally working pyproject.toml file that can install packages?

Pip supports the pyproject.toml file but so far all practical usage of the new schema requires a 3rd party tool that auto-generates these files (e.g., poetry and pip). Unlike setup.py which is already human-writeable, pyproject.toml is not…
Keto
  • 1,470
  • 1
  • 12
  • 25
58
votes
4 answers

how to run a script using pyproject.toml settings and poetry?

I am using poetry to create .whl files. I have an ftp sever runing on a remote host. I wrote a python script (log_revision.py) which save in a database the git commit, few more parameters and in the end send the the .whl(that poetry created) to…
helpper
  • 2,058
  • 4
  • 13
  • 32
54
votes
4 answers

How to specify version in only one place when using pyproject.toml?

My package version is defined in two places: __version__ = 1.2.3 in mypackage/__init__.py version = "1.2.3" in pyproject.toml (I am using Poetry) I have to update both whenever I bump the version which is annoying and not DRY. Is there a way to…
Haterind
  • 1,095
  • 1
  • 8
  • 16
51
votes
4 answers

Poetry install on an existing project Error "does not contain any element"

I am using Poetry for the first time. I have a very simple project. Basically a_project | |--test | |---test_something.py | |-script_to_test.py From a project I do poetry init and then poetry install I get the following poetry install Updating…
KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
46
votes
2 answers

Multiple top-level packages discovered in a flat-layout

I am trying to install a library from the source that makes use of Poetry, but I get this error error: Multiple top-level packages discovered in a flat-layout: ['tulips', 'fixtures']. To avoid accidental inclusion of unwanted files or…
Rodrigo
  • 135
  • 4
  • 45
  • 107
1
2 3
73 74