该错误与意外的关键字参数'exist_ok'有关。我在线尝试了许多解决方案。在显示错误“ DLL无法正确加载”之前,然后尝试了许多解决方案后,出现了此错误。
------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-22-cae538ef789d> in <module>()
----> 1 get_ipython().magic('matplotlib')
2 import matplotlib.pyplot as plt
D:\Python27\Lib\site-packages\IPython\core\interactiveshell.py in magic(self, arg_s)
2158 magic_name, _, magic_arg_s = arg_s.partition(' ')
2159 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2160 return self.run_line_magic(magic_name, magic_arg_s)
2161
2162 #-------------------------------------------------------------------------
D:\Python27\Lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line)
2079 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2080 with self.builtin_trap:
-> 2081 result = fn(*args,**kwargs)
2082 return result
2083
<decorator-gen-106> in matplotlib(self, line)
D:\Python27\Lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
186 # but it's overkill for just that one bit of state.
187 def magic_deco(arg):
--> 188 call = lambda f, *a, **k: f(*a, **k)
189
190 if callable(arg):
D:\Python27\Lib\site-packages\IPython\core\magics\pylab.py in matplotlib(self, line)
98 print("Available matplotlib backends: %s" % backends_list)
99 else:
--> 100 gui, backend = self.shell.enable_matplotlib(args.gui)
101 self._show_matplotlib_backend(args.gui, backend)
102
D:\Python27\Lib\site-packages\IPython\core\interactiveshell.py in enable_matplotlib(self, gui)
2964 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
2965
-> 2966 pt.activate_matplotlib(backend)
2967 pt.configure_inline_support(self, backend)
2968
D:\Python27\Lib\site-packages\IPython\core\pylabtools.py in activate_matplotlib(backend)
312 matplotlib.rcParams['backend'] = backend
313
--> 314 import matplotlib.pyplot
315 matplotlib.pyplot.switch_backend(backend)
316
C:\Users\sb\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\pyplot.py in <module>()
30 from cycler import cycler
31 import matplotlib
---> 32 import matplotlib.colorbar
33 import matplotlib.image
34 from matplotlib import rcsetup, style
C:\Users\sb\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\colorbar.py in <module>()
30 import matplotlib.collections as collections
31 import matplotlib.colors as colors
---> 32 import matplotlib.contour as contour
33 import matplotlib.cm as cm
34 import matplotlib.gridspec as gridspec
C:\Users\sb\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\contour.py in <module>()
16 import matplotlib.colors as mcolors
17 import matplotlib.collections as mcoll
---> 18 import matplotlib.font_manager as font_manager
19 import matplotlib.text as text
20 import matplotlib.cbook as cbook
C:\Users\sb\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\font_manager.py in <module>()
1335 _fmcache = None
1336
-> 1337 cachedir = get_cachedir()
1338 if cachedir is not None:
1339 _fmcache = os.path.join(
C:\Users\sb\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\__init__.py in wrapper()
411 nonlocal called, ret
412 if not called:
--> 413 ret = func()
414 called = True
415 _log.debug(fmt, ret)
C:\Users\sb\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\__init__.py in get_cachedir()
651 _get_config_dir, except using `$XDG_CACHE_HOME`/`~/.cache` instead.
652 """
--> 653 return _get_config_or_cache_dir(_get_xdg_cache_dir())
654
655
C:\Users\sb\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\__init__.py in _get_config_or_cache_dir(xdg_base)
613 if configdir:
614 try:
--> 615 configdir.mkdir(parents=True, exist_ok=True)
616 except OSError:
617 pass
TypeError: mkdir() got an unexpected keyword argument 'exist_ok'
我在Windows中使用python 3.7。我正在运行jupyter项目。但是,由于上述错误,我无法运行pyplot。到目前为止,我还没有找到任何可行的解决方案。导入matplotlib可以正常工作,但仅pyplot根本不起作用。