Skip to content

(Windows) Docker: markupsafe incompatibility causes Jupyter and TensorBoard errors #6

@nagumo-r

Description

@nagumo-r

I am encountering a persistent ImportError when attempting to run the Jupyter Notebooks within the Docker environment provided by this repository. The error occurs despite attempts to adjust the markupsafe library and configure the Docker execution.

The exact error message is:
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/opt/conda/lib/python3.7/site-packages/markupsafe/init.py)

Steps to Reproduce:

  1. Cloned the repository: git clone https://github.com/jonkrohn/DLTFpT.git
  2. Navigated to the repository directory.
  3. Attempted to run the Docker environment using the provided rundocker.bat file.
  4. Also tried running the Docker container using various docker run commands with different configurations (e.g., specifying shells, running in detached mode, etc.).

Environment:

  • Operating System: Windows 11 Pro
  • Docker Desktop version: 4.35.1 (173168)
  • Docker is configured to use the WSL 2 backend.

Observations:

  • The error consistently occurs when Jupyter Notebook attempts to start within the Docker container.

  • The provided rundocker.bat file also triggers the same error, indicating that the issue is not related to specific docker run command arguments.

  • The Dockerfile does not contain a SHELL instruction.

  • Downgrading markupsafe to version 1.1.1 using the following command allowed Jupyter Notebook to start successfully:

    docker run --rm -it -p 8888:8888 -v "<my local path>":/home/jovyan/work dltfpt bash -c "pip install --upgrade markupsafe==1.1.1 && jupyter notebook --ip 0.0.0.0 --port 8888 --allow-root --no-browser"
  • However, even with this workaround, running TensorBoard within the container when executing the provided notebook file notebooks/regression_in_tensorflow_with_tensorboard.ipynb results in a pkg_resources.ContextualVersionConflict related to markupsafe:

    jovyan@1c39d1d49142:~$ tensorboard --logdir='logs/' --port 6006
    Traceback (most recent call last):
      File "/opt/conda/bin/tensorboard", line 10, in <module>
        sys.exit(run_main())
      File "/opt/conda/lib/python3.7/site-packages/tensorboard/main.py", line 59, in run_main
        default.get_plugins() + default.get_dynamic_plugins(),
      File "/opt/conda/lib/python3.7/site-packages/tensorboard/default.py", line 110, in get_dynamic_plugins
        for entry_point in pkg_resources.iter_entry_points('tensorboard_plugins')
      File "/opt/conda/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2433, in load
        self.require(*args, **kwargs)
      File "/opt/conda/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2456, in require
        items = working_set.resolve(reqs, env, installer, extras=self.extras)
      File "/opt/conda/lib/python3.7/site-packages/pkg_resources/__init__.py", line 791, in resolve
        raise VersionConflict(dist, req).with_context(dependent_req)
    pkg_resources.ContextualVersionConflict: (MarkupSafe 1.1.1 (/opt/conda/lib/python3.7/site-packages), Requirement.parse('MarkupSafe>=2.1.1'), {'werkzeug'})
    
  • Attempts to upgrade markupsafe have not resolved the initial Jupyter Notebook error and have sometimes led to other dependency conflicts.

Request:

I suspect that there may be an incompatibility between the markupsafe version and other libraries within the Docker image. I would appreciate any guidance on how to resolve this issue or if there are any known workarounds. Thank you for your time and assistance.

P.S. I did most of the trouble shooting process with the support by Gemini. I am relatively new to Docker. I apologise if this report contains any inaccuracy or causes any inconvenience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions