Poetry removes importlib_metadata and other requirements when run as `--no-dev`
See original GitHub issue- 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).
- OS version and name: https://hub.docker.com/_/python:3.6-alpine
- Poetry version: 1.0.3
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/vad/874bcd90092a98b21ae73a2982246b3c
Issue
I’m using poetry inside a docker with poetry config virtualenvs.create false
. Poetry requirements are listed in my poetry.lock
as dev (they probably are dependencies of some other package). When I run poetry install --no-dev
the first time, the command runs fine but poetry removes its own requirements!
...
- Removing attrs (19.3.0)
- Removing cffi (1.14.0)
- Removing cryptography (2.8)
- Removing idna (2.8)
- Removing importlib-metadata (1.5.0)
- Removing jsonschema (3.2.0)
- Removing pycparser (2.19)
- Removing pyparsing (2.4.6)
- Removing pyrsistent (0.15.7)
- Removing zipp (3.0.0)
The second time poetry
is run, I get:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/poetry/utils/_compat.py", line 15, in <module>
from importlib import metadata
ImportError: cannot import name 'metadata'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/poetry", line 5, in <module>
from poetry.console import main
File "/usr/local/lib/python3.6/site-packages/poetry/console/__init__.py", line 1, in <module>
from .application import Application
File "/usr/local/lib/python3.6/site-packages/poetry/console/application.py", line 5, in <module>
from .commands.about import AboutCommand
File "/usr/local/lib/python3.6/site-packages/poetry/console/commands/__init__.py", line 2, in <module>
from .add import AddCommand
File "/usr/local/lib/python3.6/site-packages/poetry/console/commands/add.py", line 5, in <module>
from .init import InitCommand
File "/usr/local/lib/python3.6/site-packages/poetry/console/commands/init.py", line 16, in <module>
from poetry.utils._compat import OrderedDict
File "/usr/local/lib/python3.6/site-packages/poetry/utils/_compat.py", line 18, in <module>
import importlib_metadata as metadata
ModuleNotFoundError: No module named 'importlib_metadata'
Issue Analytics
- State:
- Created 4 years ago
- Reactions:30
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Why poetry removes some entries after running 'add'?
I'm getting this dependency added to the project, however some other dependencies are automatically removed, namely: importlib-metadata ...
Read more >Commands | Documentation | Poetry - Python dependency ...
The cache clear command removes packages from a cached repository. For example, to clear the whole cache of packages from the pypi repository,...
Read more >FoundriesFactory Release 87 (v. 1648) - Foundries.io
Read the release notes and product updates for FoundriesFactory release 87 from Foundries.io. Or browse past notes in the archives.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
One extra observation: It seems that poetry only removes packages that are mentioned in its
pyproject.toml
and/orpoetry.lock
(maybe just one, haven’t checked).I tried installing an extra package (
mysqlclient
) usingpip
directly, then ranpoetry install --no-dev
and it would again removeimportlib-metadata
and some others (all of which are listed as (indirect) dev-dependencies), but it would not removemysqlclient
, presumably since it was not listed at all.A workaround that seems to work, is to add
poetry
itself as an optional dependency:This adds a ton of extra packages to
poetry.lock
(all dependencies of poetry), but does not install them onpoetry install
. Also, it prevents removing them onpoetry install --no-dev
.Hello,
the problem here is, that
poetry
and the package are installed in the same environment. One should never mix the installation method within one environment. Either usepoetry
orpip
. But not both at the same time. Because they don’t know each other and break things when a package gets installed or removed by one or another.When using
virtualenvs.create false
make surepoetry
is installed with the installer script or as an alternative bypipx
.fin swimmer