Closed stianlagstad closed 3 years ago
Hello @stianlagstad,
there are multiple reasons for this:
First, never install poetry into the environment that should be managed by poetry. There's a good chance that otherwise dependencies needed by poetry itself gets removed or updated/downgrade when installing a project by poetry. Instead use the official installer or pipx.
Second, at the moment poetry removes dev-dependencies (and the dependecies of these dependencies) it finds some in the current environment, when running poetry install --no-dev
. In your case it finds platformdirs
and removes it. Because that's a dependency of poetry itself, poetry is unusable afterwards. With the upcoming minor release (1.2.0) this behaviour changes: Any locked packages will be kept in the environment regardless of what is asked via the install command unless the --sync option is specified..
So here is my recommendation:
virtualenvs.create false
. venvs within a docker container are absolutely valid, because they isolate the package environment from the os environment (your docker container!) to avoid conflicts.fin swimmer
Thanks for explaining (and for the fast answer), @finswimmer !
Note that with poetry 1.1.9 (due to https://github.com/python-poetry/poetry/pull/4507 likely) the behavior when installing poetry in its own virtualenv (or via pipx) changed the location where packages are being installed (into /opt/poetry/lib/python3.9/site-packages
, instead of /usr/local/lib/python3.9/site-packages/
(from the system Python)).
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
[X] I am on the latest Poetry version.
[X] I have searched the issues of this repo and believe that this is not a duplicate.
[X] If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).OS version and name: python:3.9.6-buster
Poetry version: 1.1.8
Link of a Gist with the contents of your pyproject.toml file: Repo with issue reproduced: https://github.com/stianlagstad/reproduce-poetry-virtualenv-issue
Issue
First running
poetry install --no-dev
and then runningpoetry install
leads to the errorModuleNotFoundError: No module named 'platformdirs'
. I've setup a repository that reproduces the issue: https://github.com/stianlagstad/reproduce-poetry-virtualenv-issue.Dockerfile:
Our actual Dockerfile is using multi stage builds, and in our final image (our testrunner) we want the dev dependencies installed. That's why we first do
poetry install
, and then later topoetry install --dev
.Error output:
Am I doing anything wrong? Is this expected?