ImportError: cannot import name mpl (from matplotlib import mpl)
ImportError: cannot import name mpl (from matplotlib import mpl)
我正在尝试 运行 我几年前使用 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 using import matplotlib as mpl
.
然后删除(在版本 1.5.0 中):
Remove the module matplotlib.mpl
. Deprecated in 1.3 by PR #1670 and commit 78ce67d161625833cacff23cfe5d74920248c5b2
我认为您不能从 matlotlib 导入 "mpl",因为它不存在。
我猜您想尝试导入 matplotlib AS mpl。你应该试试这个:
import matplotlib as mpl
我正在尝试 运行 我几年前使用 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
我认为您不能从 matlotlib 导入 "mpl",因为它不存在。 我猜您想尝试导入 matplotlib AS mpl。你应该试试这个:
import matplotlib as mpl