Skip to content

failure on import due to IOError writing font cache #9548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
galactica147 opened this issue Oct 23, 2017 · 7 comments · Fixed by #9676
Closed

failure on import due to IOError writing font cache #9548

galactica147 opened this issue Oct 23, 2017 · 7 comments · Fixed by #9676
Labels
Good first issue Open a pull request against these issues if there are no active ones!
Milestone

Comments

@galactica147
Copy link

galactica147 commented Oct 23, 2017

Bug report

Bug summary

When running a python script containing matplotlib module on a remote server machine, got the following errors:

import matplotlib.pyplot as plt

File "path_to_env/lib/python2.7/site-packages/matplotlib/pyplot.py", line 29, in
import matplotlib.colorbar
File "path_to_env/lib/python2.7/site-packages/matplotlib/colorbar.py", line 36, in
import matplotlib.contour as contour
File "path_to_env/lib/python2.7/site-packages/matplotlib/contour.py", line 21, in
import matplotlib.font_manager as font_manager
File "path_to_env/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1454, in
_rebuild()
File "path_to_env/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1438, in _rebuild
json_dump(fontManager, _fmcache)
File "path_to_env/lib/python2.7/site-packages/matplotlib/font_manager.py", line 966, in json_dump
json.dump(data, fh, cls=JSONEncoder, indent=2)
File "path_to_env/lib/python2.7/json/init.py", line 190, in dump
fp.write(chunk)
IOError: [Errno 122] Disk quota exceeded

Code for reproduction

python run.py

Actual outcome

as above.

I need to clarify this only crashes when running it on a remote machine. If i tried to run it locally, it worked just fine. The remote machine should be using the same env as my local because I used SGE command 'qsub -V' which would pass all my local environment variables to the remote machine. Also, I checked that I have enough space under /home/ and others on that remote machine.

Expected outcome

quietly load in or rebuild needed fonts.

Matplotlib version
matplotlib==2.1.0

  • Operating system: Linux 2.6.32-642.6.2.el6.x86_64
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 2.7.14
  • Jupyter version (if applicable):
  • Other libraries:

pip install matplotlib

@tacaswell tacaswell added this to the v2.2 milestone Oct 23, 2017
@tacaswell tacaswell added the Good first issue Open a pull request against these issues if there are no active ones! label Oct 23, 2017
@tacaswell
Copy link
Member

It is configurable, but it should be going to your home directory by default.

If you can get into an interactive debugger checking the value of _fmcache will tell you where it is actually trying to write.

Check

from matplotlib import get_cachedir 
import os

cachedir = get_cachedir()
print(os.path.join(cachedir, 'fontList.json'))

on both systems.

We probably should be more cautious when writing the cache out. Exact work:

  • catch IOError in font_manager.dump_json. There was some change in filesystem type errors between 2 and 3 iirc
  • issue an informative warning about a) why the file was not written b) how to configure the cache_dir to not try to cache the font information.

@tacaswell tacaswell changed the title where does font manager rebuild fonts to? failure on import due to IOError writing font cache Oct 23, 2017
@tacaswell tacaswell modified the milestones: v2.2, v2.1.1 Oct 23, 2017
@tacaswell
Copy link
Member

tagged as 2.1.1 as this is a 'fail on import' type bug.

@galactica147
Copy link
Author

Thanks @tacaswell ! your snippet is very useful for debugging this error!
Turns out it's indeed writing to $HOME/.matplotlib, but I didn't realize until just now that my local box's home dir doesn't sync with the one on the remote host. And it's the latter one that's full already.

@tacaswell
Copy link
Member

Re-opening this although the OP's issue is fixed, we should not be failing to import in cases like this

@galactica147 thanks for taking the time to report this and glad it is working again.

@av9ash
Copy link

av9ash commented May 6, 2022

Hi Team,

I am seeing this issue again.

import seaborn as sn
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/seaborn/init.py", line 2, in
from .rcmod import * # noqa: F401,F403
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/seaborn/rcmod.py", line 7, in
from . import palettes
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/seaborn/palettes.py", line 9, in
from .utils import desaturate, get_color_cycle
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/seaborn/utils.py", line 14, in
import matplotlib.pyplot as plt
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/matplotlib/pyplot.py", line 49, in
import matplotlib.colorbar
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/matplotlib/colorbar.py", line 21, in
from matplotlib import _api, collections, cm, colors, contour, ticker
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/matplotlib/contour.py", line 13, in
from matplotlib.backend_bases import MouseButton
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 46, in
from matplotlib import (
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/matplotlib/textpath.py", line 8, in
from matplotlib import _text_helpers, dviread, font_manager
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/matplotlib/font_manager.py", line 1447, in
fontManager = _load_fontmanager()
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/matplotlib/font_manager.py", line 1442, in _load_fontmanager
json_dump(fm, fm_path)
File "/opt/test-result-jenie/venv_trj/lib/python3.8/site-packages/matplotlib/font_manager.py", line 1007, in json_dump
_log.warning('Could not save font_manager cache {}'.format(e))
OSError: [Errno 122] Disk quota exceeded

matplotlib version: 3.5.2
seaborn version: 0.11.2

Can't clear the cache as don't have the permissions to do so.
Appreciate any help on the issue, Thanks in Advance.

@tacaswell
Copy link
Member

@av9ash Can you please make a new issue with this information?

@av9ash
Copy link

av9ash commented May 6, 2022

Ok will do, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Open a pull request against these issues if there are no active ones!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants