You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jupyter Notebook中pip安装perfplot后导入报TypeError问题求助

解决perfplot导入时的TypeError问题

这个错误的核心原因是你的numpy版本太低——np.dtype[ScalarType]这种下标写法是numpy 1.20及以上版本才支持的语法,老版本numpy的np.dtype不允许这样用,才会抛出'type' object is not subscriptable的错误。

解决步骤:

  • 先确认当前numpy版本,在Jupyter单元格里运行:
    import numpy
    print(numpy.__version__)
    
    如果输出低于1.20,就需要更新。
  • 更新numpy,执行命令:
    pip install --upgrade numpy
    
    要是全局安装权限不够,就加--user参数:pip install --upgrade numpy --user
  • 重启Jupyter的内核(顶部菜单栏"Kernel"→"Restart"),然后再试import perfplot。

如果更新numpy后还是有问题,可以试试重新安装perfplot:

pip uninstall -y perfplot numpy_typing
pip install perfplot

内容的提问来源于stack exchange,提问作者mudders

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 07:52:01