-2

Lambda Error Output

{
  "errorMessage": "[Errno 30] Read-only file system: '/home/sbx_user1051'",
  "errorType": "OSError",
  "stackTrace": [
    "  File \"/var/lang/lib/python3.8/imp.py\", line 234, in load_module\n    return load_source(name, filename, file)\n",
    "  File \"/var/lang/lib/python3.8/imp.py\", line 171, in load_source\n    module = _load(spec)\n",
    "  File \"<frozen importlib._bootstrap>\", line 702, in _load\n",
    "  File \"<frozen importlib._bootstrap>\", line 671, in _load_unlocked\n",
    "  File \"<frozen importlib._bootstrap_external>\", line 843, in exec_module\n",
    "  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n",
    "  File \"/app/app.py\", line 2, in <module>\n    nltk.download('punkt')\n",
    "  File \"/var/lang/lib/python3.8/site-packages/nltk/downloader.py\", line 777, in download\n    for msg in self.incr_download(info_or_id, download_dir, force):\n",
    "  File \"/var/lang/lib/python3.8/site-packages/nltk/downloader.py\", line 642, in incr_download\n    yield from self._download_package(info, download_dir, force)\n",
    "  File \"/var/lang/lib/python3.8/site-packages/nltk/downloader.py\", line 699, in _download_package\n    os.makedirs(download_dir)\n",
    "  File \"/var/lang/lib/python3.8/os.py\", line 213, in makedirs\n    makedirs(head, exist_ok=exist_ok)\n",
    "  File \"/var/lang/lib/python3.8/os.py\", line 223, in makedirs\n    mkdir(name, mode)\n"
  ]
}

My Dockerfile

FROM public.ecr.aws/lambda/python:3.8
WORKDIR /app
COPY requirements.txt .
COPY kbtrial.csv .
RUN pip3 install -r requirements.txt
#RUN pip install -r requirements.txt
COPY app.py  .
CMD ["/app/app.handler"]

my python code is correct as its running with desired output on my console so obviously there's an issue with lambda please tell me the steps i need to take to fix this !

David Maze
  • 130,717
  • 29
  • 175
  • 215

1 Answers1

0

With Lambda there are restrictions to the underlying file system, looks like you are trying to download file to a specific folder. You can use /tmp instead of the current directory where you are trying to download the file. The Lambda execution environment provides a file system for your code to use at /tmp. This space has a fixed size of 512 MB.

Vikram S
  • 792
  • 4
  • 7