将matplotlib.pyplot导入Jupyter笔记本时遇到问题。
我卸载了matplotlib(和seaborn)并重新安装它们。但这并没有解决问题。
然而,确切的代码可以在我的第二台计算机上正常运行。
我研究了stackoverflow,并尝试了一个建议的东西(请参见帖子的底部) - 仍然给出了完全相同的错误。
这里有一些相关信息
Platform : win-64, Windows 7 Enterprise
Conda version : 4.4.7
Conda-build version : 3.0.27
Python version : 3.6.4.final.0
JupyterLab : v0.27.0
Matplotlib version 2.1.2
这是我想要运行的内容:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
我收到如下错误:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-d2e7a3f2c9b4> in <module>()
1 import pandas as pd
2 import numpy as np
----> 3 import matplotlib.pyplot as plt
---------------------------------------------------------------------------
4 import seaborn as sns
5 get_ipython().run_line_magic('matplotlib', 'inline')
~\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 from matplotlib import style
34 from matplotlib import _pylab_helpers, interactive
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\colorbar.py in <module>()
34 import matplotlib.collections as collections
35 import matplotlib.colors as colors
---> 36 import matplotlib.contour as contour
---------------------------------------------------------------------------
37 import matplotlib.cm as cm
38 import matplotlib.gridspec as gridspec
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\contour.py in <module>()
19 import matplotlib.colors as colors
20 import matplotlib.collections as mcoll
---> 21 import matplotlib.font_manager as font_manager
---------------------------------------------------------------------------
22 import matplotlib.text as text
23 import matplotlib.cbook as cbook
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\font_manager.py in <module>()
56
57 import matplotlib
---> 58 from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir
---------------------------------------------------------------------------
59 from matplotlib.compat import subprocess
60 from matplotlib.fontconfig_pattern import (
ImportError: DLL load failed: The specified procedure could not be found.
---------------------------------------------------------------------------
我尝试
时遇到同样的错误import matplotlib as mpl
mpl.use('tkagg')
import matplotlib.pyplot as plt