title: How can I make packages installed using Poetry accessible in Docker?
body: <p>I have a Django REST framework API that I'm trying to run in Docker. The project uses Poetry 1.1.12. When running, I can see that Poetry is installed correctly, and that Poetry installs the packages in my <code>pyproject.toml</code>, including Django. I'm using supervisor to run the API using Daphne, as well as some other tasks (like collecting static files).</p>
  <p>However, when supervisor runs the app, I get:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/home/docker/api/manage.py&quot;, line 22, in &lt;module&gt;
      main()
    File &quot;/home/docker/api/manage.py&quot;, line 13, in main
      raise ImportError(
  ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
  Traceback (most recent call last):
    File &quot;/home/docker/api/manage.py&quot;, line 11, in main
      from django.core.management import execute_from_command_line
  ModuleNotFoundError: No module named 'django'
  </code></pre>
  <p>Notice how I set <code>POETRY_VIRTUALENVS_CREATE=false</code> and <code>ENV PATH=&quot;/root/.local/bin:${PATH}&quot;</code>. According to the poetry installation script, that is the path that needs to be added to PATH.</p>
  <p>Here is an abridged versioned of my Dockerfile:</p>
  <pre><code>FROM python:3.9-slim-buster
  ENV PATH=&quot;/root/.local/bin:${PATH}&quot;
  
  RUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends \
      ... \
      curl \
      supervisor \
      &amp;&amp; curl -sSL 'https://install.python-poetry.org' | python - &amp;&amp; poetry --version \
      &amp;&amp; apt-get remove -y curl \
      &amp;&amp; apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
      &amp;&amp; apt-get clean -y &amp;&amp; rm -rf /var/lib/apt/lists/* \
      &amp;&amp; rm -rf /var/lib/apt/lists/*
  
  COPY poetry.lock pyproject.toml /home/docker/api/
  
  WORKDIR /home/docker/api
  
  RUN if [ &quot;$DEBUG&quot; = &quot;false&quot; ] \
      ; then POETRY_VIRTUALENVS_CREATE=false poetry install --no-dev --no-interaction --no-ansi -vvv --extras &quot;production&quot; \
      ; else POETRY_VIRTUALENVS_CREATE=false poetry install --no-interaction --no-ansi -vvv --extras &quot;production&quot; \
      ; fi
  
  COPY . /home/docker/api/
  COPY .docker/services/api/files/supervisor.conf /etc/supervisor/conf.d/
  
  CMD [&quot;supervisord&quot;, &quot;-n&quot;]
  </code></pre>
  <p>Which is pretty much how I see others doing it. Any ideas?</p>