Matplotlib Issues

Hi,

I am running most of my commands on a headless server, and tried to run the feature-table summary commands and got this error message:

Plugin error from feature-table:

Invalid DISPLAY variable

I have seen that other people have run into similar issues, and ran this command as suggested in other posts:

echo “backend: Agg” > ~/.config/matplotlib/matplotlibrc

but now I get this message:

Bad key ““backend” on line 1 in
/home/am14262/.config/matplotlib/matplotlibrc.
You probably need to get an updated matplotlibrc file from


or from the matplotlib source distribution

However, the command runs and produces a .qzv which I can then transfer on my laptop to visualize. I have matplotlib version 2.1.1.

I am not really sure what’s wrong…Should I ignore that message?

Thanks

Hi @Alex_14262! Which QIIME 2 release are you using? The matplotlib backend issue should be resolved in QIIME 2 releases 2017.9 and later.

You could try setting an environment variable instead of using a matplotlib config file. You may need to first remove the config file you created for the environment variable to take effect.

export MPLBACKEND='Agg'

You can run the above command in your terminal, or put it in your ~/.bashrc file for it to take effect each time you open a new terminal window.

If that doesn’t work, and you’re using a release of QIIME 2 that is 2017.9 or later, can you please send me the ~/.config/matplotlib/matplotlibrc file as an attachment?

Hi,

Running conda list when logged on the server I get this:

q2-alignment 2017.12.0 py35_0 qiime2/label/r2017.12
q2-composition 2017.12.0 py35_0 qiime2/label/r2017.12
q2-cutadapt 2017.12.0 py35_0 qiime2/label/r2017.12
q2-dada2 2017.12.1 py35_0 qiime2/label/r2017.12
q2-deblur 2017.12.0 py35_0 qiime2/label/r2017.12
q2-demux 2017.12.0 py35_0 qiime2/label/r2017.12
q2-diversity 2017.12.0 py35_0 qiime2/label/r2017.12
q2-emperor 2017.12.0 py35_0 qiime2/label/r2017.12
q2-feature-classifier 2017.12.0 py35_0 qiime2/label/r2017.12
q2-feature-table 2017.12.0 py35_0 qiime2/label/r2017.12
q2-gneiss 2017.12.0 py35_0 qiime2/label/r2017.12
q2-longitudinal 2017.12.0 py35_0 qiime2/label/r2017.12
q2-metadata 2017.12.0 py35_0 qiime2/label/r2017.12
q2-phylogeny 2017.12.0 py35_0 qiime2/label/r2017.12
q2-quality-control 2017.12.0 py35_0 qiime2/label/r2017.12
q2-quality-filter 2017.12.0 py35_0 qiime2/label/r2017.12
q2-sample-classifier 2017.12.0 py35_0 qiime2/label/r2017.12
q2-taxa 2017.12.0 py35_0 qiime2/label/r2017.12
q2-types 2017.12.0 py35_0 qiime2/label/r2017.12
q2-vsearch 2017.12.0 py35_0 qiime2/label/r2017.12
q2cli 2017.12.0 py35_0 qiime2/label/r2017.12
q2templates 2017.12.0 py35_0 qiime2/label/r2017.12
qiime2 2017.12.1 py35_0 qiime2/label/r2017.12

So most of the plugins are 2017.12.0, and a few 2017.12.1, so later release than 2017.9 anyway.

I have entered the command you suggested in the terminal and re-run the feature-table summary command, but still got the same message.

I have looked in the matplotlibrc file but there is nothing apart from this line: “backend: Agg”, which I guess is consistent with the message: Bad key ““backend” on line 1 in /home/am14262/.config/matplotlib/matplotlibrc, as that’s the only line…

Hi @Alex_14262! I’m not exactly sure what’s going on here. Just to be sure, can you try removing the matplotlibrc file you created, run the export MPLBACKEND='Agg' command in your terminal, and rerun the feature-table command? Also, please send me the output from running echo $MPLBACKEND after running the export command above.

Also, are you running these commands directly on the server, or are they being submitted to a cluster queueing system or being run from a shell script? I wonder if the environment variables in the execution environment are different from your user environment.

1 Like

Hi

This worked!

echo $MPLBACKEND
Agg

I am running the commands from a shell script within my virtual box, but I am logged in on the server - this is because I have had memory issues when trying to run some of the commands directly on my laptop.

Just for clarification - any idea what the problem actually was? It may be worth mentioning that I got the Bad key message mentioned above when running all the commands in the Moving Pictures tutorial, but I still got the output - and I can't see anything wrong with the visualizations created, so I don't know if I should rerun the whole analysis. This happened only after creating the matplotlibrc file with: echo “backend: Agg” > ~/.config/matplotlib/matplotlibrc .

Thanks for helping with this issue

Great, glad it's working!

Since you're running the commands within a shell script on the server, it's possible that environment variable was being unset or overridden within the script (i.e. the environment variable that QIIME 2 was setting automatically for headless servers). It sounds like you have the correct configuration in place now though for the shell script's environment variables, so hopefully this won't continue to be an issue (let us know if that isn't the case).

I don't know what the exact issue was, but I suspect you had a corrupted matplotlib config file somehow, and matplotlib was upset about that. Perhaps matplotlib was just issuing a warning though, which is why the commands continued to run and produce outputs. This is just a configuration issue with matplotlib working on a headless server, so the results you obtained are reliable and won't have changed in any way based on the matplotlib error/warning. No need to rerun the analyses luckily!

Let us know if you run into any more issues. I think it was just a corrupted config file, and now that it's removed things should run smoothly.

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.