From 87c968bc7df97d5b7938d99073aac3744a80310e Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Tue, 10 Nov 2015 12:57:22 -0800 Subject: [PATCH 1/2] Do not run Windows' file system convert tool --- lib/matplotlib/animation.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index a44ed865cd43..c5dc3c94254a 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -262,6 +262,10 @@ def isAvailable(cls): Check to see if a MovieWriter subclass is actually available by running the commandline tool. ''' + if platform.system() == 'Windows' and cls.bin_path() == 'convert': + # On Windows, the full path to convert must be specified in + # matplotlibrc since convert is also the name of a system tool. + return False try: p = subprocess.Popen(cls.bin_path(), shell=False, From a30ec664e39c27feaef595d2d81046222ec9afee Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Wed, 25 Nov 2015 15:18:29 -0800 Subject: [PATCH 2/2] On Windows, initialize the animation.convert_path setting from the Registry --- lib/matplotlib/animation.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index c5dc3c94254a..1667d79a3088 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -33,7 +33,7 @@ from matplotlib.cbook import iterable, is_string_like from matplotlib.compat import subprocess from matplotlib import verbose -from matplotlib import rcParams +from matplotlib import rcParams, rcParamsDefault # Process creation flag for subprocess to prevent it raising a terminal # window. See for example: @@ -262,9 +262,7 @@ def isAvailable(cls): Check to see if a MovieWriter subclass is actually available by running the commandline tool. ''' - if platform.system() == 'Windows' and cls.bin_path() == 'convert': - # On Windows, the full path to convert must be specified in - # matplotlibrc since convert is also the name of a system tool. + if not cls.bin_path(): return False try: p = subprocess.Popen(cls.bin_path(), @@ -549,6 +547,27 @@ def delay(self): def output_args(self): return [self.outfile] + @classmethod + def _init_from_registry(cls): + if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert': + return + from matplotlib.externals.six.moves import winreg + for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY): + try: + hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, + 'Software\\Imagemagick\\Current', + 0, winreg.KEY_QUERY_VALUE | flag) + binpath = winreg.QueryValueEx(hkey, 'BinPath')[0] + winreg.CloseKey(hkey) + binpath += '\\convert.exe' + break + except Exception: + binpath = '' + rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath + + +ImageMagickBase._init_from_registry() + @writers.register('imagemagick') class ImageMagickWriter(MovieWriter, ImageMagickBase):