Ich möchte einen Nltk-Dienst in Docker ausführen. Allerdings bekomme ich immer die Fehlermeldung "'nltk' ist kein Paket". Können Sie herausfinden, was falsch läuft? Während des Builds funktioniert alles einwandfrei, die Nltk-Version wird gedruckt. Wenn mit docker-compose up nltk
den Container starten bekomme ichNLTK funktioniert nicht in Docker
$ Docker-komponieren bis nltk
Recreating nltk
Attaching to nltk
nltk | Traceback (most recent call last):
nltk | File "/var/www/nltk.py", line 1, in <module>
nltk | from nltk.corpus import brown
nltk | File "/var/www/nltk.py", line 1, in <module>
nltk | from nltk.corpus import brown
nltk | ModuleNotFoundError: No module named 'nltk.corpus'; 'nltk' is not a package
Docker-compose.yml
nltk:
build: docker/nltk
container_name: nltk
volumes:
- ./volumes/nltk/var/www/nltk.py:/var/www/nltk.py
environment:
HOME: /var/www
Dockerfile
FROM python:3.6
RUN mkdir /var/www
ENV HOME /var/www
WORKDIR /var/www
RUN pip install -U nltk
RUN pip install -U numpy
RUN python -m nltk.downloader -d $HOME/nltk_data all
RUN python -c "import nltk"
RUN python -c "import nltk; print(nltk.__version__)"
EXPOSE 80
CMD [ "python", "/var/www/nltk.py" ]
nltk.py
import nltk
from nltk.corpus import brown
brown.words()
Großen. Ich denke, das hat den Trick gemacht. Vielen Dank! Ich werde die endgültige Version veröffentlichen – Sebastian