Skip to content
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

UV Fails to install with Docker #3782

Closed
Nneji123 opened this issue May 23, 2024 · 3 comments
Closed

UV Fails to install with Docker #3782

Nneji123 opened this issue May 23, 2024 · 3 comments
Labels
question Asking for clarification or support

Comments

@Nneji123
Copy link

I've been using uv with my docker builds for the past few months. I just encountered the following error when trying to install requirements in my container. Here's the error:

 => ERROR [celery-beat stage-0  8/12] RUN --mount=type=cache,target=/root/.cache/pip /root/.cargo/bin/uv pip install --no-cache -r requirements.txt      0.8s
------
 > [celery-beat stage-0  8/12] RUN --mount=type=cache,target=/root/.cache/pip /root/.cargo/bin/uv pip install --no-cache -r requirements.txt:
0.675 error: No Python interpreters found in virtual environments

Here's the Dockerfile:

FROM python:3.8.13-slim-bullseye

WORKDIR /app

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    netcat \
    wget \
    unzip \
    dpkg && \
    rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade setuptools

ENV VIRTUAL_ENV=/usr/local
ADD --chmod=655 https://astral.sh/uv/install.sh /install.sh
RUN /install.sh && rm /install.sh

ADD requirements.txt /app/requirements.txt

RUN --mount=type=cache,target=/root/.cache/pip /root/.cargo/bin/uv pip install --no-cache -r requirements.txt # the build fails at this stage

# Copy project files into container
ADD . /app

RUN sed -i "s/raise RuntimeError(\"populate() isn't reentrant\")/self.app_configs = {}/g" /usr/local/lib/python3.8/site-packages/django/apps/registry.py

# Copy the entrypoint script
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

EXPOSE 8000

ENTRYPOINT ["/app/entrypoint.sh"]

In the Dockerfile I am using the latest version of uv.

How do I go about resolving this issue?

@charliermarsh
Copy link
Member

Can you try removing ENV VIRTUAL_ENV=/usr/local, and instead passing --system to your uv pip install invocation?

@charliermarsh charliermarsh added the question Asking for clarification or support label May 23, 2024
@Nneji123
Copy link
Author

Thank you very much for the quick response. The suggestion you offered fixed the issue.

@zanieb
Copy link
Member

zanieb commented May 23, 2024

Thanks for reporting and checking back in! For additional reference, this is a duplicate of #3765 which has a bit more discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

3 participants