I want to deploy my app on HuggingFaceSpaces but encountered an error:
There was a problem when trying to write in your cache folder (/.cache/huggingface/hub). You should set the environment variable TRANSFORMERS_CACHE to a writable directory.
[nltk_data] Downloading package punkt to /nltk_data...
Traceback (most recent call last):
File "/APP/rag_lchain.py", line 19, in <module>
nltk.download('punkt')
File "/usr/local/lib/python3.12/site-packages/nltk/downloader.py", line 774, in download
for msg in self.incr_download(info_or_id, download_dir, force):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/nltk/downloader.py", line 642, in incr_download
yield from self._download_package(info, download_dir, force)
File "/usr/local/lib/python3.12/site-packages/nltk/downloader.py", line 698, in _download_package
os.makedirs(download_dir, exist_ok=True)
File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/nltk_data'
There was a problem when trying to write in your cache folder (/.cache/huggingface/hub). You should set the environment variable TRANSFORMERS_CACHE to a writable directory.
[nltk_data] Downloading package punkt to /nltk_data...
Traceback (most recent call last):
File "/APP/rag_lchain.py", line 19, in <module>
nltk.download('punkt')
File "/usr/local/lib/python3.12/site-packages/nltk/downloader.py", line 774, in download
for msg in self.incr_download(info_or_id, download_dir, force):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/nltk/downloader.py", line 642, in incr_download
yield from self._download_package(info, download_dir, force)
File "/usr/local/lib/python3.12/site-packages/nltk/downloader.py", line 698, in _download_package
os.makedirs(download_dir, exist_ok=True)
File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/nltk_data'
My Dockerfile:
FROM python:3.12
WORKDIR /APP
COPY requirements.txt .
COPY sparse_encoder.json .
COPY README.md .
RUN pip install --no-cache-dir -r requirements.txt
COPY rag_lchain.py .
EXPOSE 7860
ENV GRADIO_SERVER_NAME="0.0.0.0"
CMD ["python", "rag_lchain.py"]
What I can do to fix this problem?