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.
python-poetry
1,329
questions
321
votes
17
answers
281k
views
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?
180
votes
18
answers
139k
views
How to import an existing requirements.txt into a Poetry project?
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 ...
178
votes
4
answers
86k
views
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 ...
170
votes
5
answers
118k
views
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 ...
126
votes
16
answers
264k
views
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 ...
110
votes
13
answers
226k
views
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 ...
105
votes
3
answers
181k
views
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 ...
104
votes
5
answers
62k
views
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 ...
102
votes
2
answers
64k
views
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 ...
88
votes
16
answers
162k
views
Why is my poetry virtualenv using the system python instead of the pyenv python that I set?
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 ...
84
votes
7
answers
71k
views
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....
81
votes
5
answers
53k
views
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 ...
79
votes
1
answer
58k
views
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 ...
76
votes
21
answers
202k
views
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 ...
75
votes
5
answers
158k
views
How to run a script using pyproject.toml settings and poetry?
I am using poetry to create .whl files. I have an FTP sever running 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 ...
72
votes
6
answers
26k
views
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 ...
67
votes
2
answers
50k
views
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 ...
60
votes
7
answers
47k
views
Installing a specific PyTorch build (f/e CPU-only) with Poetry
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 ...
53
votes
5
answers
67k
views
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"
...
53
votes
5
answers
76k
views
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 ...
52
votes
1
answer
26k
views
Feature comparison between npm, pip, pipenv and Poetry package managers [closed]
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 ...
50
votes
4
answers
189k
views
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
...
46
votes
5
answers
25k
views
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.
...
44
votes
2
answers
10k
views
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 ...
39
votes
3
answers
79k
views
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
├── ...
38
votes
6
answers
43k
views
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 ...
38
votes
2
answers
73k
views
How to force reinstall Poetry environment from scratch?
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 ...
34
votes
6
answers
16k
views
poetry returns 'dyld: Library not loaded ... image not found' following brew install while inside virtual environment
I ran brew install postgresql while inside a poetry environment. Since then, I can't interact with poetry.
λ ~/ poetry
dyld: Library not loaded: /usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python....
34
votes
5
answers
45k
views
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. ...
31
votes
6
answers
40k
views
How to run FastAPI application from Poetry?
I have a fastapi project built by poetry. I want to run the application with a scripts section in pyproject.tom like below:
poetry run start
What is inside double quotes in the section?
[tool.poetry....
29
votes
4
answers
27k
views
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 ...
29
votes
2
answers
10k
views
What's the difference between the [tool.poetry] and [project] tables in pyproject.toml? [closed]
Context
So, I'm trying to create a new Python package following this tutorial: https://packaging.python.org/en/latest/tutorials/packaging-projects/
As the tutorial says, in my pyproject.toml I should ...
29
votes
2
answers
12k
views
How do I specify "extra" / bracket dependencies in a pyproject.toml?
I'm working on a project that specifies its dependencies using Poetry and a pyproject.toml file to manage dependencies. The documentation for one of the libraries I need suggests pip-installing with ...
29
votes
2
answers
38k
views
How to find the list of available versions for an specific package with Poetry?
Using Poetry, I want to find all versions of an specific package that are available for install. Is it possible to achieve that?
(Similar to Python and pip, list all versions of a package that's ...
29
votes
2
answers
24k
views
What is the difference between `poetry lock` and `poetry update --lock`?
What is the difference between poetry update --lock and poetry lock? I wasn't able to find much useful hints in the official docs and I know that both are not the same since we recently had to switch ...
29
votes
2
answers
9k
views
Does Poetry have an equivalent for the flag "--trusted-host" that is available on Pip?
I wish to start using poetry on some projects at work, where I am stuck behind corporate filters that sometimes interfere with certs.
If I use pip, I can ignore SSL errors by doing something like the ...
28
votes
4
answers
15k
views
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 ...
28
votes
8
answers
25k
views
poetry installation failing on Mac OS, says "should_use_symlinks"
I am trying to install poetry using the following command
curl -sSL https://install.python-poetry.org | python3 -
but it is failing with the following exception:
Exception: This build of python ...
28
votes
3
answers
25k
views
How poetry knows my package is located in the src folder?
I have a simple question.
I used to create a poetry project with my package at root.
project.toml
mypackage
+- __init__.py
+- mypackage.py
+- test_mypackage.py
I recently moved my tests in ...
28
votes
1
answer
45k
views
How can I specify which Python version poetry should create venv?
I started using Poetry recently. I really like straightforward package management, but I can’t seem to resolve one thing: The Python version it should use. I have Python 3.9 and 3.7 on my machine. 3.7 ...
28
votes
4
answers
21k
views
Error: Python packaging tool 'setuptools' not found
I have a poetry project that is not using setuptools
[tool.poetry.dependencies]
python = ">=3.9,<3.11"
opencv-python = "^4.7.0.68"
tensorflow-macos = "^2.11.0"
...
26
votes
4
answers
35k
views
Why does poetry build raise ModuleOrPackageNotFound exception?
I want to use poetry to build and distribute Python source packages, but after poetry init I get an error running poetry build.
ModuleOrPackageNotFound
No file/folder found for package mdspliter....
25
votes
1
answer
41k
views
Where to locate virtual environment installed using poetry | Where to find poetry installed virtual environment
I installed poetry using the following command:-
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python -
To know more ...
25
votes
5
answers
60k
views
poetry install | SolverProblemError Because my_project depends on string (*) which doesn't match any versions, version solving failed
I am yet to use poetry to run project, so excuse lack of understanding.
I successfully installed the poetry python library manager, using:
curl -sSL https://raw.githubusercontent.com/python-poetry/...
25
votes
3
answers
17k
views
What's the difference between extras and groups in poetry?
So far I have used poetry extras to install optional dependencies. For instance, in pyproject.toml I have defined
[tool.poetry.dependencies]
...
jupyter = { version = "^1.0.0", optional = ...
25
votes
1
answer
14k
views
What files/directories should I add to .gitignore when using Poetry, the Python package manager?
I'm using a very new Python package manager called Poetry.
It creates several files/directories upon creating a new project (environment), but I'm not sure which one I should add to .gitignore for ...
24
votes
3
answers
23k
views
Python Poetry: how to specify platform-specific dependency alternatives?
Some background:
The project I'm working on uses python-ldap library. Since we are a mixed-OS development team (some use Linux, some macOS and some Windows), I'm trying to make the project build on ...
24
votes
3
answers
11k
views
How to have a single source of truth for poetry and pre-commit package version?
I'm looking into this Python project template. They use poetry to define dev dependencies
[tool.poetry.dev-dependencies]
black = {version = "*", allow-prereleases = true}
flake8 = "*&...
24
votes
2
answers
5k
views
How to reuse pyproject.toml in monorepo with Poetry?
There are multiple projects in my monorepo, which has package management via Poetry individually. For instance,
monorepo
├── a
│ └── pyproject.toml
├── b
│ └── pyproject.toml
└── c
└── ...
23
votes
2
answers
17k
views
Poetry: Failed to unlock the collection
On a fresh poetry install, I get the following error trying to install anything:
(base) ➜ celeba poetry add numpy
Failed to unlock the collection!
How can I fix this?