poetry: Wrong environment selected when installed with pipx

  • 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: python:3.7.13-slim-buster
  • Poetry version: 1.2.0
  • Link of a Gist with the contents of your pyproject.toml file: n/a

Issue

When I’ve installed poetry using pipx in my Docker image and then set poetry not to create virtual environment - poetry installed all dependencies in venv created by pipx for poetry instead in system’s python.

Any workaround for this?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

I disagree to this, but it’s opinion-based, so let’s not get into this.

I’ve raised a bug that there is inconsistency between native installer & pipx/pip installation.
I’ve also submitted a workaround to that. I’m good now.

Docker container is already venv

No, no, no. It’s repeated a lot, but is not getting true 😉

Python’s venv isolate dependencies from the global available python packages. As soon as you install two or more Python projects globally their dependencies influence each other. This is the case inside and outside docker. So if you need a reproducible python environment always use venv.

I’ve managed to trick poetry into knowing that he’s installed inside it’s virtual environment.

Like poetry does it when it’s installed by the script - I’ve created a file poetry_env inside it’s venv.

touch /root/.local/pipx/venvs/poetry/poetry_env

alongside with:

poetry config virtualenvs.create false

it did the job and poetry installed dependencies system-wide.