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

求助:PyCharm中使用Jupyter插件无法导入Python库模块

PyCharm Jupyter插件无法导入Python库的解决办法

遇到的错误示例:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 import numpy as np

ModuleNotFoundError: No module named 'numpy'
  • 核对Jupyter内核与项目解释器是否一致

    1. 打开PyCharm的File > Settings > Project: [你的项目名] > Python Interpreter,复制当前项目的解释器路径
    2. 在Jupyter notebook单元格里执行import sys; print(sys.executable),对比输出路径和上面的是否相同
    3. 路径不符的话,点击Jupyter界面右上角的内核名称,选择Change Kernel,切换到项目对应的解释器内核;如果没有对应内核,在PyCharm终端执行python -m ipykernel install --user --name=项目专属内核,重启Jupyter后选择新内核
  • 确认库安装在当前解释器环境

    1. 在PyCharm的Python Interpreter界面,查看已安装包列表,检查numpy、pandas是否存在
    2. 未安装就点击+搜索安装;已安装但报错,选中包点击右上角的✓重新安装
    3. 也可以直接在PyCharm终端执行pip install numpy pandas(确保终端左侧显示项目虚拟环境标识,比如(venv))
  • 修复Jupyter插件关联

    1. 打开File > Settings > Plugins,找到Jupyter插件,先禁用再启用,重启PyCharm
    2. 终端执行pip install --upgrade ipykernel jupyter,更新相关依赖
  • 清理缓存

    1. 清除PyCharm缓存:File > Invalidate Caches...,勾选Clear file system cache and local history,点击Invalidate and Restart
    2. 删除项目目录下的.ipynb_checkpoints文件夹,重新打开notebook

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.30 22:21:35