File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -1087,17 +1087,13 @@ def func(current_frame: int, total_frames: int) -> Any
1087
1087
# If we have the name of a writer, instantiate an instance of the
1088
1088
# registered class.
1089
1089
if isinstance (writer , str ):
1090
- if writers .is_available (writer ):
1091
- writer = writers [writer ](fps , ** writer_kwargs )
1092
- else :
1093
- alt_writer = next (iter (writers ), None )
1094
- if alt_writer is None :
1095
- raise ValueError ("Cannot save animation: no writers are "
1096
- "available. Please install ffmpeg to "
1097
- "save animations." )
1098
- _log .warning ("MovieWriter %s unavailable; trying to use %s "
1099
- "instead." , writer , alt_writer )
1100
- writer = alt_writer (fps , ** writer_kwargs )
1090
+ try :
1091
+ writer_cls = writers [writer ]
1092
+ except RuntimeError : # Raised if not available.
1093
+ writer_cls = PillowWriter # Always available.
1094
+ _log .warning ("MovieWriter %s unavailable; using Pillow "
1095
+ "instead." , writer )
1096
+ writer = writer_cls (fps , ** writer_kwargs )
1101
1097
_log .info ('Animation.save using %s' , type (writer ))
1102
1098
1103
1099
if 'bbox_inches' in savefig_kwargs :
You can’t perform that action at this time.
0 commit comments