简体   繁体   English

LightGBM和Catboost都已安装,但是在Jupyter中导入时会给出ModuleNotFoundError

[英]LightGBM and Catboost are both installed but give ModuleNotFoundError when imported in Jupyter

I have successfully installed the CatBoost and LightGbM modules using the command prompt. 我已经使用命令提示符成功安装了CatBoost和LightGbM模块。 It gave me the message Successfully installed catboost-0.2.5 (I also previously tried another one). 它给了我消息成功安装catboost-0.2.5(我之前也尝试过另一个)。 However, for both of them I have an identical error when I try to import both of them in a jupyter notebook: 但是,当我尝试将它们都导入到jupyter笔记本中时,对于它们两个,我都会遇到相同的错误:

import lightgbm as lgb

I get: 我得到:

ModuleNotFoundError: No module named 'lightgbm'

and I get an identical error with CatBoost as well. 而且CatBoost也会出现相同的错误。

Any ideas? 有任何想法吗? Thank you! 谢谢!

As discussed in the chat , it turns out that the environment where your Jupyter notebooks run and the one where you have installed the packages are different. 聊天中所讨论的,事实证明Jupyter笔记本运行的环境与安装软件包的环境不同。

Since pip reports both packages installed in your "main" environment (ie the one coming up when you simply open a Windows command prompt), what you should do is open Jupyter from the command prompt, as 由于pip报告了两个安装在“主”环境中的软件包(即,仅在打开Windows命令提示符时就会出现的软件包),因此您应该从命令提示符处打开Jupyter,如下所示:

jupyter notebook

and your packages will indeed be available for importing, as we confirmed indeed. 正如我们确认的那样,您的软件包确实可以导入。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spark 错误:“ModuleNotFoundError: No module named 'notebook'”即使安装了 jupyter - Spark Error: “ModuleNotFoundError: No module named 'notebook'” even when jupyter is installed 我已经成功安装了 lightgbm 但无法在 jupyter 中运行 - I have installed lightgbm successfully but can't run in jupyter 当我尝试导入 jupyter notebook(使用 venv)时,安装的包给出了“ModuleNotFoundError” - Installed package giving "ModuleNotFoundError" when I try to import into jupyter notebook (using venv) 在命令行上安装了一个 package 并且可以通过命令行导入它。 在 jupyter notebook 中导入时收到 ModuleNotFoundError - Installed a package on command line and can import it via command line. Receive ModuleNotFoundError when importing in jupyter notebook Anaconda无法识别:xgboost,catboost和lightgbm - Anaconda does not recognize: xgboost, catboost and lightgbm 将 python package 安装到 conda 虚拟环境,Jupyter Notebook 中的 ModuleNotFoundError - Installed python package to conda virtual environment, ModuleNotFoundError in Jupyter Notebook Jupyter 中的 ModuleNotFoundError 而 pip freeze 显示其已安装 - ModuleNotFoundError in Jupyter while pip freeze shows its installed Jupyter ModuleNotFoundError - Jupyter ModuleNotFoundError 安装 jupyter 时语法“jupiter notebook”无效+导入 - Invalid Syntax 'jupiter notebook' while jupyter is installed +imported 安装包时 JetBrains DataSpell ModuleNotFoundError 错误 - JetBrains DataSpell ModuleNotFoundError error when package is installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM