# Converting a pipeline from docker to singularity, Not able to access matplotlib/fontlist-v330

**URL:** <https://community.seqera.io/t/converting-a-pipeline-from-docker-to-singularity-not-able-to-access-matplotlib-fontlist-v330/1447>\
**Category:** Ask for help\
**Tags:** nextflow, singularity\
**Created:** [November 17, 2024, 5:37pm UTC](https://community.seqera.io/t/converting-a-pipeline-from-docker-to-singularity-not-able-to-access-matplotlib-fontlist-v330/1447 "2024-11-17T17:37:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shubham1637](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/shubham1637/32/1246_2.png) [@shubham1637](https://community.seqera.io/u/shubham1637)\
**Post date:** [November 17, 2024, 5:37pm UTC](https://community.seqera.io/t/converting-a-pipeline-from-docker-to-singularity-not-able-to-access-matplotlib-fontlist-v330/1447/1 "2024-11-17T17:37:50Z")

</div>

Hi,  
I am trying to convert a pipeline from docker to singularity.  
I have added this in config/default.config file

```auto
singularity {
    enabled = true
    autoMounts = true
}

```

However, I get this error related to matplotlib directory inside the container.

```auto
ERROR ~ Error executing process > 'parse_SourceVariant_workflow:parse_rMATS (1)'

Caused by:
  Process `parse_SourceVariant_workflow:parse_rMATS (1)` terminated with an error exit status (1)

Command executed:

  set -euo pipefail
  
  moPepGen parseRMATS --se rmats_se.txt --a5ss rmats_a5ss.txt --a3ss rmats_a3ss.txt --mxe rmats_mxe.txt --ri rmats_ri.txt --index-dir index --output-path UCLA0001_rMATS_rMATS.gvf --min-ijc 1 --min-sjc 1 --source rMATS

Command exit status:
  1

Command output:
  (empty)

Command error:
  INFO: Environment variable SINGULARITYENV_TMPDIR is set, but APPTAINERENV_TMPDIR is preferred
  INFO: Environment variable SINGULARITYENV_NXF_DEBUG is set, but APPTAINERENV_NXF_DEBUG is preferred
  Traceback (most recent call last):
    File "/usr/local/lib/python3.8/site-packages/matplotlib/font_manager.py", line 1429, in <module>
      fontManager = json_load(_fmcache)
    File "/usr/local/lib/python3.8/site-packages/matplotlib/font_manager.py", line 1012, in json_load
      with open(filename, 'r') as fh:
  FileNotFoundError: [Errno 2] No such file or directory: '/opt/matplotlib/fontlist-v330.json'

```

To solve this, in each module/.nf file I am adding

```auto
script:
    """
    export MPLCONFIGDIR=$PWD/.matplotlib
    mkdir -p $MPLCONFIGDIR
    """"

```

However, I think there should be a better way to it globally? I am a consumer of the pipeline.

I tried adding in the config file

```auto
process {
    beforeScript = '''
    export MPLCONFIGDIR=$PWD/.matplotlib
    mkdir -p $MPLCONFIGDIR
    '''

    environment = [
        'MPLCONFIGDIR': "$PWD/.matplotlib"
    ]
}

```

but then I get the same error again.

```auto
Command exit status:
  1

Command output:
  (empty)

Command error:
  INFO: Environment variable SINGULARITYENV_TMPDIR is set, but APPTAINERENV_TMPDIR is preferred
  INFO: Environment variable SINGULARITYENV_NXF_DEBUG is set, but APPTAINERENV_NXF_DEBUG is preferred
  Traceback (most recent call last):
    File "/usr/local/lib/python3.8/site-packages/matplotlib/font_manager.py", line 1429, in <module>
      fontManager = json_load(_fmcache)
    File "/usr/local/lib/python3.8/site-packages/matplotlib/font_manager.py", line 1012, in json_load
      with open(filename, 'r') as fh:
  FileNotFoundError: [Errno 2] No such file or directory: '/opt/matplotlib/fontlist-v330.json'
.
.
.
  OSError: [Errno 30] Read-only file system: '/opt/matplotlib/fontlist-v330.json.matplotlib-lock'

```

---

<div class="post-metadata">

**Author:** ![mahesh.binzerpanchal](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/mahesh.binzerpanchal/32/253_2.png) [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Post date:** [November 19, 2024, 8:33am UTC](https://community.seqera.io/t/converting-a-pipeline-from-docker-to-singularity-not-able-to-access-matplotlib-fontlist-v330/1447/2 "2024-11-19T08:33:09Z")

</div>

If the docker container runs some script through the `--entrypoint` ( use `docker inspect` to see it ) these scripts are not run when using `apptainer` or `singularity`. This usually means you have to check if something is set in the environment and if not then source that entrypoint script so stuff does get setup as it should. I had to do this for Quarto recently and added this to my bash code in the end:

```auto
    # Fix Quarto for apptainer
    ENV_QUARTO="\${ENV_QUARTO:-/opt/conda/etc/conda/activate.d/quarto.sh}"
    set +u
    if [-z "\${QUARTO_DENO}"] && [-f "\${ENV_QUARTO}"]; then
        source "\${ENV_QUARTO}"
    fi
    set -u

```
