NLTK 抛出 FileNotFoundError: [Errno 2] 在 ['/tmp', '/var/tmp', '/usr/tmp', '/'] 中找不到可用的临时目录

问题描述 投票:0回答:1

嘿谁能告诉一下这是什么原因

FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/']

我正在 Docker ecs fargate 任务上运行,这会引发错误。

我尝试在本地构建并运行映像,它工作正常,但在 ecs fargate 上会抛出错误。

下面是我的 docker 文件

FROM python:3.10-slim-bullseye

RUN apt-get update \
    && apt-get install --yes build-essential python3-dev default-libmysqlclient-dev libpq-dev pkg-config\
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN groupadd -r runner && useradd -r -g runner runner

COPY requirements /requirements
RUN pip install -U pip
RUN pip install -r requirements/base.txt
COPY handler.py /
COPY document_generation /document_generation

RUN export PYTHONPATH="${PYTHONPATH}:$(pwd)";

WORKDIR /

# Create a temporary directory and set permissions
RUN mkdir -p /documents_api_tmp && chmod 777 -R /documents_api_tmp && chmod o+t -R /documents_api_tmp
ENV TMPDIR=/documents_api_tmp

# Debugging step: Check directory permissions and disk usage
RUN df -h \
    && du -sh /documents_api_tmp

USER runner

CMD ["python", "handler.py"]


python docker-compose amazon-ecs
1个回答
0
投票

我在 lambda 函数中遇到了同样的错误。你设法解决这个问题了吗?如果是这样怎么办?

© www.soinside.com 2019 - 2024. All rights reserved.