-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python deps not found on path after installing with Poetry (and Poetry installed with pipx) #5927
Comments
... and haven't created and activated a virtual environment yourself? Where are you expecting your flake8 to show up? I think that in 1.1.13 it will appear in poetry's own virtual environment which makes no sense at all. In later 1.2.0 betas poetry tries to add it to the system python which, per #5928, probably won't work. If you don't want poetry to manage your virtual environment you almost certainly nevertheless do want a virtual environment, you are just taking responsibility for doing this yourself. |
In the default Python environment, so you can see flake8 from running
Usually yes, but this is in a Docker container so I don't think I need a virtual environment. |
As I say, more recent poetry versions will put this into the system python, so if that's what you want then you're good. Just install poetry==1.2.0b2. |
Actually if you're installing via pipx that's probably not true - because pipx puts a new python interpreter into the virtual environment so poetry will still find that and still install flake8 into poetry venv. But if you install as |
It works when Poetry is installed with the installation script (without needing a virtual environment or Poetry 1.2.0b2). FROM python:3.8-slim-buster
RUN apt-get update && \
apt-get install -y curl
RUN curl -sSL https://install.python-poetry.org | python -
# Put Poetry on the path.
ENV PATH=/root/.local/bin:$PATH
WORKDIR /app
COPY pyproject.toml poetry.toml poetry.lock ./
RUN poetry install --no-root
COPY . .
ENTRYPOINT [] So the problem is specifically when Poetry is installed with pipx.
Do you know if there's a way to disable that? I expected Poetry to behave the same way when installed with the script or pipx. |
No way so far as I know - poetry looks for the python that is executing it and works from there. To my mind it's inadvisable not to be explicit about your virtual environment, whether that be by creating one manually or by having poetry do it for you. You can always tweak your path afterwards so that executables in that environment are available to all. |
Ok, I found a solution that uses pipx by activating a virtual environment in Docker. FROM python:3.8.13-slim-buster
RUN pip install pipx && \
pipx install poetry
# Put Poetry on the path.
ENV PATH=/root/.local/bin:$PATH
WORKDIR /app
COPY pyproject.toml poetry.toml poetry.lock ./
ENV VIRTUAL_ENV=/opt/env
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN poetry install --no-root
COPY . .
ENTRYPOINT [] |
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. |
Issue
I'm trying to install Python dependencies with Poetry, after installing Poetry with pipx. The problem is that the Python dependencies installed with Poetry aren't being found on the path.
Here's my demo directory structure:
I'm installing flake8 as a dev dependency.
I've disabled Poetry's virtualenv creation.
Here's a Dockerfile to provide a minimal working example:
The flake8 command isn't found in the Docker container.
But Poetry shows that it knows about flake8.
Running flake8 with
poetry run
works.But I thought that
poetry run
wasn't required if you disabled Poetry's virtualenv feature.The text was updated successfully, but these errors were encountered: