Pycharm Jupyter ModuleNotFoundError 问题解决

Pycharm Jupyter ModuleNotFoundError 问题解决

0. 问题描述

通过 Pycharm 启动的 Jypyter,发生 ModuleNotFoundError 的问题。

实际上相关 Module 已经通过 pip install 安装完成,所以怀疑是 Jupyter 的问题。

1. 解决方法

执行下面命令,找打 kernel 的配置文件,

jupyter kernelspec list

--- output
D:\anaconda3\envs\ragdemo\share\jupyter\kernels\python3
---

用记事本打开 kernel.json 文件,修改 python 为我们创建的虚拟环境的 python.exe 文件,

修改前,

{
 "argv": [
  "python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3 (ipykernel)",
 "language": "python",
 "metadata": {
  "debugger": false
 }
}

修改后,

{
 "argv": [
  "D:/anaconda3/envs/ragdemo\\python.exe",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3 (ipykernel)",
 "language": "python",
 "metadata": {
  "debugger": false
 }
}

重新启动 Jupyter 就 Okay 了。

完结!

猜你喜欢

转载自blog.csdn.net/engchina/article/details/134869397