我无法从matplotlib导入pyplot

xtfmy6hx  于 2023-11-22  发布在  其他
关注(0)|答案(1)|浏览(155)

当使用

from matplotlib import pyplot as plt

字符串
错误代码:

from matplotlib import pyplot as plt
  File "C:\Users\dell\AppData\Roaming\Python\Python37\site-packages\matplotlib\pyplot.py", line 2362, in <module>
    install_repl_displayhook()
  File "C:\Users\dell\AppData\Roaming\Python\Python37\site-packages\matplotlib\pyplot.py", line 126, in install_repl_displayhook
    ip.enable_gui(ipython_gui_name)
  File "C:\Users\dell\AppData\Roaming\Python\Python37\site-packages\IPython\core\interactiveshell.py", line 3378, in enable_gui
    raise NotImplementedError('Implement enable_gui in a subclass')
NotImplementedError: Implement enable_gui in a subclass

k75qkfdt

k75qkfdt1#

我刚刚使用pandas显示一个图时遇到了问题,并得到了同样的错误。这为我解决了这个问题。不得不降级ipython。现在图从命令提示符/ PowerShell显示。

pip uninstall ipython 
pip install ipython==7.24.1

字符串
另一个解决方法是手动为matplotlib定义后端:

matplotlib.use('TkAgg')


虽然具体设置后端显然是皱眉后.出于某种原因只是运行下面的查询似乎也工作:

matplotlib.rcParams['backend']


这允许使用较新的ipython版本(用8.17.2测试)

相关问题