python - 安装包时 JetBrains DataSpell ModuleNotFoundError 错误
问题描述
我使用ipynb
-文件。当我尝试导入prophet
库时,我得到了这个:
ModuleNotFoundError:没有名为“先知”的模块。
但是这个包已经安装并且它在我当前的环境中。Jupyter 服务器的解释器有prophet
库。当我将光标移动到库名称时,DataSpell 会显示其信息:
如果我from prophet import Prophet
在 python 控制台中执行一切正常!我认为问题出在 Jupyter 笔记本上,但找不到。
解决方案
最近碰到这个。 这个答案让我走上了正确的轨道。
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
二进制文件(并且所有导入都运行良好)。
推荐阅读
- mongodb - Mongodb 文档验证失败,代码为 121
- xcode - 包含多个二进制框架(包装 C 库)的 Swift 包
- database - Mongo db 没有启动
- azure - 天蓝色政策“修改”效果与补救
- shell - Gitlab 作业因 while 循环而失败
- datagrid - 我可以阻止人们在 ag-Grid 中编辑特定单元格吗?
- javascript - 如何使用 travel advisor api 加载酒店的图像和描述
- arduino - Arduino IDE 检测到错误的端口
- r - 如何在 R 中编写 CSV 文件
- wordpress - 如何将 wordpress 站点设置为独立 html 站点的子站点?