我正在尝试运行几年前编写的代码,该代码使用 matplotlib
中的 mpl
。以前运行得很好,但现在突然抛出错误:
from matplotlib import mpl
ImportError: cannot import name mpl
我使用的是 Python 2.7 和 matplotlib 1.5.2。
最佳答案
您需要使用:
import matplotlib as mpl
<小时/>
它确实在早期版本中有效,但它首先被弃用(在版本 1.3 中):
The
mpl
module is now deprecated. Those who relied on this module should transition to simply usingimport matplotlib as mpl
.
然后删除(在版本 1.5.0 中):
Remove the module
matplotlib.mpl
. Deprecated in 1.3 by PR #1670 and commit 78ce67d161625833cacff23cfe5d74920248c5b2
关于python - ImportError:无法导入名称 mpl (来自 matplotlib import mpl),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44499971/