首页 > 解决方案 > 安装包时 JetBrains DataSpell ModuleNotFoundError 错误

问题描述

我使用ipynb-文件。当我尝试导入prophet库时,我得到了这个:

ModuleNotFoundError:没有名为“先知”的模块。

但是这个包已经安装并且它在我当前的环境中。Jupyter 服务器的解释器有prophet库。当我将光标移动到库名称时,DataSpell 会显示其信息:

截屏

如果我from prophet import Prophet在 python 控制台中执行一切正常!我认为问题出在 Jupyter 笔记本上,但找不到。

标签: pythonpycharmmodulenotfounderrorprophetdataspell

解决方案


最近碰到这个。 这个答案让我走上了正确的轨道。

jupyter也安装在我的默认 Ubuntu python 环境之一中,DataSpell 正在使用二进制文件启动服务器,而不是安装在我在 DataSpell 中创建的环境中。

(巧合的是,那个默认环境也有一些常用的包,比如pandas安装,所以直到我在 DataSpell 管理的环境中安装了一个包,而我的 Ubuntu 默认 python 环境中还没有这个包。)

  • 我找到了默认的 jupyter 二进制文件:which jupyter.
  • 检查脚本:nano /home/<user>/.local/bin/jupyter
  • 看到它安装的python环境:#!/usr/bin/python3.8在脚本的顶部
  • jupyter从该环境中卸载:python3.8 -m pip uninstall jupyter

然后 DataSpell 使用了正确的jupyter二进制文件(并且所有导入都运行良好)。


推荐阅读