diff --git a/Zarr.m b/Zarr.m index 7c6fa9a..9bdd83e 100644 --- a/Zarr.m +++ b/Zarr.m @@ -33,9 +33,15 @@ % Check if the ZarrPy module is loaded already. If not, load % it. - sys = py.importlib.import_module('sys'); - loadedModules = dictionary(sys.modules); - if ~loadedModules.isKey("ZarrPy") + try + sys = py.importlib.import_module('sys'); + loadedModuleNames = string( py.list( sys.modules.keys() ) ); + requiresZarrPyReload = ~any(loadedModuleNames == "ZarrPy"); + catch + requiresZarrPyReload = true; + end + + if requiresZarrPyReload zarrModule = py.importlib.import_module('ZarrPy'); py.importlib.reload(zarrModule); end