"The system cannot find the file specified" during pgm.figure.savefig()
See original GitHub issueI just installed daft (pip install daft
) on my Windows machine but the last step of all of the samples is failing while trying to save the file.
Source Code (from sample):
from matplotlib import rc
rc("font", family="serif", size=12)
rc("text", usetex=True)
import daft
pgm = daft.PGM([3.6, 1.8], origin=[2.2, 1.6], aspect=2.1)
pgm.add_node(daft.Node("confused", r"confused", 3.0, 3.0))
pgm.add_node(daft.Node("ugly", r"ugly font", 3.0, 2.0, observed=True))
pgm.add_node(daft.Node("bad", r"bad talk", 5.0, 2.0, observed=True))
pgm.add_edge("confused", "ugly")
pgm.add_edge("ugly", "bad")
pgm.add_edge("confused", "bad")
pgm.render()
pgm.figure.savefig("badfont.pdf")
pgm.figure.savefig("badfont.png", dpi=150)
Error message:
Traceback (most recent call last):
File ".\job_manager\compiler\visualizer.py", line 15, in <module>
pgm.figure.savefig("badfont.pdf")
File "C:\Program Files\Python36\lib\site-packages\matplotlib\figure.py", line 2035, in savefig
self.canvas.print_figure(fname, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\backend_bases.py", line 2263, in print_figure
**kwargs)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\backends\backend_pdf.py", line 2586, in print_pdf
self.figure.draw(renderer)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\figure.py", line 1475, in draw
renderer, self, artists, self.suppressComposite)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\image.py", line 141, in _draw_list_compositing_images
a.draw(renderer)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\axes\_base.py", line 2607, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\image.py", line 141, in _draw_list_compositing_images
a.draw(renderer)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\text.py", line 2301, in draw
Text.draw(self, renderer)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\text.py", line 706, in draw
bbox, info, descent = textobj._get_layout(renderer)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\text.py", line 300, in _get_layout
ismath=False)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\backends\backend_pdf.py", line 2148, in get_text_width_height_descent
renderer=self)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\texmanager.py", line 501, in get_text_width_height_descent
dvifile = self.make_dvi(tex, fontsize)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\texmanager.py", line 365, in make_dvi
texfile], tex)
File "C:\Program Files\Python36\lib\site-packages\matplotlib\texmanager.py", line 335, in _run_checked_subprocess
stderr=subprocess.STDOUT)
File "C:\Program Files\Python36\lib\subprocess.py", line 336, in check_output
**kwargs).stdout
File "C:\Program Files\Python36\lib\subprocess.py", line 403, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Program Files\Python36\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Program Files\Python36\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
"The system cannot find the file specified" during pgm.figure ...
I just installed daft (pip install daft) on my Windows machine but the last step of all of the samples is failing while...
Read more >Save plot to image file instead of displaying it using Matplotlib
When using matplotlib.pyplot.savefig , the file format can be specified by the extension: from matplotlib import pyplot as plt plt.savefig('foo.png') ...
Read more >Save figure to specific file format - MATLAB saveas - MathWorks
To save the current figure, specify fig as gcf . saveas( fig , filename , formattype ) creates the file using the specified...
Read more >The System Cannot Find the File Specified Error in Windows ...
The System Cannot Find the File Specified Error in Windows 11/10 [Tutorial]Sometimes Windows backups may fail when you try to create a file...
Read more >Reading and saving image files with Python, OpenCV (imread ...
In Python and OpenCV, you can read (load) and write (save) image files with cv2.imread() and cv2.imwrite(). Images are read as NumPy array ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi there, I encountered the same issue and solved it by changing this line of code
rc("text", usetex=True)
intorc("text", usetex=False)
Matplotlib requires MiKTeX and GhostScript for rendering text with LaTeX.
Also add
C:\Program Files\MiKTeX 2.9\miktex\bin\x64
to your path.