Daniel Reichenpfader
03/25/2025, 3:52 PM#!/usr/bin/env python
import nltk
print("Downloading NLTK data..")
nltk.download("punkt_tab")
pyproject.toml
[tool.bentoml.build.python]
packages = ["nltk"]
[tool.bentoml.build.docker]
setup_script = "./setup.py"
Building the bento works, but when I then try containerizing with
bentoml containerize mybento:id --opt platform=linux/amd64
I get the following error as nltk cannot be found. I am on bentoml version 1.4.6
=> ERROR [base-container 13/15] RUN chmod +x ./env/docker/script__2721a2a460e1713162fe15a0bf0a1043 && ./env/docker/script__2721a2a460e1713162fe15a0bf0a1043 0.2s
------
> [base-container 13/15] RUN chmod +x ./env/docker/script__2721a2a460e1713162fe15a0bf0a1043 && ./env/docker/script__2721a2a460e1713162fe15a0bf0a1043:
0.204 Traceback (most recent call last):
0.204 File "/home/bentoml/bento/./env/docker/script__2721a2a460e1713162fe15a0bf0a1043", line 3, in module
0.205 import nltk
0.205 ModuleNotFoundError: No module named 'nltk'
------
Dockerfile:45
--------------------
43 | RUN --mount=type=cache,target=/root/.cache/ uv pip install -r ./env/python/requirements.txt
44 |
45 | >>> RUN chmod +x ./env/docker/script__2721a2a460e1713162fe15a0bf0a1043 && ./env/docker/script__2721a2a460e1713162fe15a0bf0a1043
46 |
47 | COPY --chown=bentoml:bentoml . ./
--------------------Jian Shen Yap
03/26/2025, 3:12 AMclass MyService:
def __init__(self):
nltk.download("punkt_tab")Daniel Reichenpfader
03/26/2025, 10:29 AM