[Matplotlib-users] RuntimeError: Could not open facefile
Hi,
I'm running into this RuntimeError: Could not open facefile
c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf;
Cannot_Open_Resource when I'm trying to save out a series of *.png files in
a loop. It crashes on this error after many passes through the loop and
successful files get created, but then always on the same pass it does
this. The full traceback is here:
File
"C:\Users\E440710\Desktop\PythonTransfer\fittslaw_ThroughputCalc_AS_break.py",
line 744, in
fig.savefig(fname, transparent = True)
File "c:\Python32\lib\site-packages\matplotlib\figure.py", line 1174, in
savefig
self.canvas.print_figure(*args, **kwargs)
File "c:\Python32\lib\site-packages\matplotlib\backend_bases.py", line
2027, in print_figure
**kwargs)
File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
line 451, in print_png
FigureCanvasAgg.draw(self)
File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
line 400, in draw
self.figure.draw(self.renderer)
File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "c:\Python32\lib\site-packages\matplotlib\figure.py", line 887, in
draw
func(*args)
File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "c:\Python32\lib\site-packages\matplotlib\axes.py", line 1985, in
draw
a.draw(renderer)
File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "c:\Python32\lib\site-packages\matplotlib\axis.py", line 1043, in
draw
ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
renderer)
File "c:\Python32\lib\site-packages\matplotlib\axis.py", line 994, in
_get_tick_bboxes
extent = tick.label1.get_window_extent(renderer)
File "c:\Python32\lib\site-packages\matplotlib\text.py", line 743, in
get_window_extent
bbox, info = self._get_layout(self._renderer)
File "c:\Python32\lib\site-packages\matplotlib\text.py", line 296, in
_get_layout
ismath=False)
File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
line 182, in get_text_width_height_descent
font = self._get_agg_font(prop)
File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
line 223, in _get_agg_font
font = FT2Font(str(fname))
RuntimeError: Could not open facefile
c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf;
Cannot_Open_Resource
I've tried the various fixes that have been suggested - removing the
fontList.py3k.cache and even the removing the .matplotlib directory.
However when I run my script that's producing the error the directory gets
recreated along with the fontList.py3k.cache which must be pointing to the
wrong path?
When I check the path
c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf where
matplotlib is looking for the resource it cannot open - the Vera.ttf is
there.
This only happens after many iterations through the loop that is saving out
the *.png files and I have no idea why.
The relevant code from my script is here:
for p in plotData[k]["data"]:
#print("p in plotData[k]:",p)
a = numpy.array((loc[0],loc[1]))
b = numpy.array((p[0],p[1]))
distValue = (numpy.sqrt(numpy.sum((a-b)**2) ))/86.0 #divide by
86 because that was the ppi on the display used to collect the data
if p[2] == 1:
hit_x.append(loc[0]-p[0])
hit_y.append(loc[1]-p[1])
frame_hit_x = loc[0]-p[0]
frame_hit_y = loc[1]-p[1]
print("frame_x:", frame_hit_x)
files = []
if size == (0.25,0.25) and makeMovie:
fig = plt.figure()
print("fig:", fig)
plt.plot(frame_hit_x,frame_hit_y,color='green',marker='o',linestyle='')
plt.axis('scaled')
plt.axis([-100,100,-100,100])
fname =
"subj{:g}_size{:g}_hit_x{:g}.png".format(Subject,btnSize,frame_hit_x)
print('saving frame', fname)
fig.savefig(fname, transparent = True)
files.append(fname)
I'm on a Win7 64bit using python 3.2 and matplotlib version 1.2.x
Any help would be greatly appreciated!
Andy
--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] RuntimeError: Could not open facefile
Ok thank you - so one way to work around it is to just generate the files I
want in batches so Windows won't run out of file handles - but is there a
way to know how many handles are available? I'm trying to animate some data
and I don't really know how many frames there are - could be thousands.
Andy
On Fri, Mar 23, 2012 at 3:45 PM, Michael Droettboom wrote:
> This is a known bug on Windows where it runs out of file handles after a
> while.
>
> This commit was an attempt to fix it, but it doesn't seem to work:
>
>
> https://github.com/matplotlib/matplotlib/commit/4cb2aaa87b0aa9efe7178d7510d3d091ef5206df
>
> I think we need a Windows user/developer/expert to get to the bottom of
> why file handles are not being freed to the OS.
>
> Mike
>
>
> On 03/23/2012 04:35 PM, Andrew Smart wrote:
>
> Hi,
> I'm running into this RuntimeError: Could not open facefile
> c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf;
> Cannot_Open_Resource when I'm trying to save out a series of *.png files in
> a loop. It crashes on this error after many passes through the loop and
> successful files get created, but then always on the same pass it does
> this. The full traceback is here:
>
> File
> "C:\Users\E440710\Desktop\PythonTransfer\fittslaw_ThroughputCalc_AS_break.py",
> line 744, in
> fig.savefig(fname, transparent = True)
> File "c:\Python32\lib\site-packages\matplotlib\figure.py", line 1174, in
> savefig
> self.canvas.print_figure(*args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\backend_bases.py", line
> 2027, in print_figure
> **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
> line 451, in print_png
> FigureCanvasAgg.draw(self)
> File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
> line 400, in draw
> self.figure.draw(self.renderer)
> File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
> draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\figure.py", line 887, in
> draw
> func(*args)
> File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
> draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\axes.py", line 1985, in
> draw
> a.draw(renderer)
> File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
> draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\axis.py", line 1043, in
> draw
> ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
> renderer)
> File "c:\Python32\lib\site-packages\matplotlib\axis.py", line 994, in
> _get_tick_bboxes
> extent = tick.label1.get_window_extent(renderer)
> File "c:\Python32\lib\site-packages\matplotlib\text.py", line 743, in
> get_window_extent
> bbox, info = self._get_layout(self._renderer)
> File "c:\Python32\lib\site-packages\matplotlib\text.py", line 296, in
> _get_layout
> ismath=False)
> File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
> line 182, in get_text_width_height_descent
> font = self._get_agg_font(prop)
> File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
> line 223, in _get_agg_font
> font = FT2Font(str(fname))
> RuntimeError: Could not open facefile
> c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf;
> Cannot_Open_Resource
>
> I've tried the various fixes that have been suggested - removing the
> fontList.py3k.cache and even the removing the .matplotlib directory.
> However when I run my script that's producing the error the directory gets
> recreated along with the fontList.py3k.cache which must be pointing to the
> wrong path?
>
> When I check the path
> c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf where
> matplotlib is looking for the resource it cannot open - the Vera.ttf is
> there.
>
> This only happens after many iterations through the loop that is saving
> out the *.png files and I have no idea why.
>
> The relevant code from my script is here:
>
> for p in plotData[k]["data"]:
> #print("p in plotData[k]:",p)
> a = numpy.array((loc[0],loc[1]))
> b = numpy.array((p[0],p[1]))
> distValue = (numpy.sqrt(numpy.sum((a-b)**2) ))/86.0 #divide by
> 86 because that was the ppi on the display us
Re: [Matplotlib-users] How to start when you don't know what to do
Do you happen to have a really good programmer nearby? I usually do a ton of dumb trial and error for a week, banging my head against the wall, until my super good programmer colleague comes over and goes "goddammit what are you trying to do?", then in like 2 minutes he shows me where I went wrong. But I find that I learn the most after a lot of dumb trial and error, then someone who knows what they are doing shows me. On Tue, Jan 15, 2013 at 2:09 PM, Nicolas Rougier wrote: > > > I do exactly that from time to time (copying a graphic) and I always start > looking at the matplotlib gallery (http://matplotlib.org/gallery.html) > for what is the most similar figure and starts from here (after removing > what is not necessary). Most important is identifying the kind of axis > necessary (cartesian, log, polar, ...) > > Some examples at: http://www.loria.fr/~rougier/coding/gallery/ > > Some really nice graphics (but difficult) to try to copy at: > > http://www.improving-visualisation.org/visuals > > > > Nicolas > > > On Jan 15, 2013, at 20:52 , Steven Boada wrote: > > > Heyya list. > > > > I must admit that my matplotlib-foo is only so so. One of the biggest > > problems that I face is seeing cool stuff around the net, and thinking, > > "that's pretty neat, I'd like to copy it." In reality, I have no idea > > how I would go about creating something like that. > > > > Here's an example: http://imgur.com/JdkR4 > > > > Just a little circular histogram thing with some annotations. Obviously, > > I'd need the annotate command for the words, but what about the arcs? No > > idea, off hand. So my question is, how do you decode (read: what to > > think about) figures that you see, and turn them into actual python? > > Sure I could post on stack exchange or email all you people every time, > > but I want to be *better* at this. And while some people are going to > > scoff and reply "that's easy, silly" it's not so for some. I just hate > > to admit it's me. > > > > Thanks for the advice. > > > > -- > > > > Steven Boada > > > > Doctoral Student > > Dept of Physics and Astronomy > > Texas A&M University > > [email protected] > > > > > > > -- > > Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS > > and more. Get SQL Server skills now (including 2012) with LearnDevNow - > > 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts. > > SALE $99.99 this month only - learn more at: > > http://p.sf.net/sfu/learnmore_122512 > > ___ > > Matplotlib-users mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > -- > Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS > and more. Get SQL Server skills now (including 2012) with LearnDevNow - > 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts. > SALE $99.99 this month only - learn more at: > http://p.sf.net/sfu/learnmore_122512 > ___ > Matplotlib-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS and more. Get SQL Server skills now (including 2012) with LearnDevNow - 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only - learn more at: http://p.sf.net/sfu/learnmore_122512___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
