Reputation: 119
I use Ipython Notebook on Mac OS 10.11.2. I run Python 3.5.1 and Matplotlib 1.5.1 and Seaborn version 0.6.0:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
I recently started having issues when plotting using Matplotlib/Seaborn. After generating a few plots within the same notebook, the notebook cell where my latest plot is being generated crashes with the error:
OSError: [Errno 24] Too many open files: '/Library/Fonts/Arial.ttf'
I am still able to run other cells but the same error is raised every time I try to plot something within this notebook until I restart it.
I tried increasing the files limit by running:
sudo launchctl limit maxfiles 10000000 10000000
It seems to have helped a bit the issue persists. Any suggestion on how to solve the issue once and for all would be appreciated. Thanks !
Below is the exact output of the error:
OSError Traceback (most recent call last)
/Users/spfraib/anaconda/lib/python3.5/site-packages/IPython/core/formatters.py in __call__(self, obj)
/Users/spfraib/anaconda/lib/python3.5/site-packages/IPython/core/pylabtools.py in <lambda>(fig)
/Users/spfraib/anaconda/lib/python3.5/site-packages/IPython/core/pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/backends/backend_agg.py in draw(self)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/figure.py in draw(self, renderer)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/axes/_base.py in draw(self, renderer, inframe)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/axis.py in draw(self, renderer, *args, **kwargs)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/axis.py in _get_tick_bboxes(self, ticks, renderer)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/text.py in get_window_extent(self, renderer, dpi)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/text.py in _get_layout(self, renderer)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/backends/backend_agg.py in get_text_width_height_descent(self, s, prop, ismath)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/mathtext.py in parse(self, s, dpi, prop)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/mathtext.py in __init__(self, *args, **kwargs)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/mathtext.py in __init__(self, *args, **kwargs)
/Users/spfraib/anaconda/lib/python3.5/site-packages/matplotlib/mathtext.py in __init__(self, default_font_prop, mathtext_backend)
OSError: [Errno 24] Too many open files: '/Library/Fonts/Arial.ttf'
Upvotes: 3
Views: 8141
Reputation: 15895
The solution described in the blog post solved the problem for me. I experienced these errors while using Sublime Text editor, which uses a python–driven plugin system.
Create /Library/LaunchDaemons/limit.maxfiles.plist
with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>524288</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
Create /Library/LaunchDaemons/limit.maxproc.plist
with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxproc</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxproc</string>
<string>2048</string>
<string>2048</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>
Make sure the permissions are right,
-rw-r--r-- 1 root wheel 541 Oct 5 14:14 limit.maxfiles.plist
-rw-r--r-- 1 root wheel 586 Oct 5 14:14 limit.maxproc.plist
and then:
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
sudo launchctl load -w /Library/LaunchDaemons/limit.maxproc.plist
At first, it didn't work for me (check ulimit -a
) but after the reboot, it worked like a charm. No more annoying errors.
Upvotes: 1
Reputation: 431
Before starting ipython try increasing the file limit, e.g. ulimit -n 4096
for up to 4096 file descriptors. El Capitan defaults to a limit of 256 file descriptors.
Upvotes: 2