Article
· May 13, 2023 2m read

a virgin Jupyter-Notebook

Following one package from the last contest I met a strange problem.
There was the requirement to install jupyter-notebook
I work on Windows and there was some old Python installed
No big surprise: Installation of jupyter-notebook failed
Therefore, the latest version of Python was installed fast.

Big disappointment: the installation of jupyter-notebook failed again!
Because the new installation of Python didn't upgrade the old one.
And also the environment variable PATH was not cleaned
This was not obvious immediately and took endless time and effort.

Several cycles of installation and de-installations followed.
After a lot of manual intervention in Windows settings finally 
allowed Jupyter-Notebook to start.
Though it was not willing to operate in the virtual environment (venv).

This was the point when I had just enough.
I said to myself: "What you do here is just nonsense!"
After cleaning my workspace and the traces of all the failing
installations (several GB) I took a different approach.

  • The idea was to use my well-working Docker installation: 
  • Find a simple container with installed Jupyter-Notebook
  • Fill it with all the required Python modules
  • Forget about venv. More virtual than a Docker container is not possible.
  • Link your local directory into the container. So copying into the container is not necessary.
  • Not to forget the mapping for default port 8888 

The Docker container was built and running in no time 
compared to all my previous attempts. 
It was composed of these 2 files:

Dockerfile

ARG IMAGE=jupyter/base-notebook
FROM $IMAGE
USER root
COPY ./requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt

If you don't have requirements just un-comment the last 2 lines.

docker-compose.yaml

version: '3.9'
services:
  notebook:
    build:
      context: .
      dockerfile: Dockerfile
    entrypoint: jupyter notebook
                --allow-root
                --no-browser
                --ip 0.0.0.0
                --port 8888
                --NotebookApp.token=''
                --NotebookApp.password=''
                --notebook-dir=/ext
    ports:
    - 8888:8888
    volumes:
    - ./:/ext
    

And now after starting the container your Jupyter-Notebook is ready for access.

http://localhost:8888/

This was definitely easier than my previous attempts.
I felt it as a personal success, as this was a totally new territory for me.
 

Discussion (0)1
Log in or sign up to continue