Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32fe716

Browse files
committed
Merge pull request matplotlib#3275 from cgohlke/patch-5
TST: Fix ImportError: No module named 'mpl_toolkits'
2 parents e2fbeb3 + 8289514 commit 32fe716

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/matplotlib/testing/decorators.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,15 @@ def find_dotted_module(module_name, path=None):
308308
"""A version of imp which can handle dots in the module name"""
309309
res = None
310310
for sub_mod in module_name.split('.'):
311-
res = file, path, _ = imp.find_module(sub_mod, path)
312-
path = [path]
313-
if file is not None:
314-
file.close()
311+
try:
312+
res = file, path, _ = imp.find_module(sub_mod, path)
313+
path = [path]
314+
if file is not None:
315+
file.close()
316+
except ImportError:
317+
# assume namespace package
318+
path = sys.modules[sub_mod].__path__
319+
res = None, path, None
315320
return res
316321

317322
mod_file = find_dotted_module(func.__module__)[1]

0 commit comments

Comments
 (0)