Search code examples
pythonjupyter-notebookjupyterlightgbmcatboost

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. It gave me the message Successfully installed catboost-0.2.5 (I also previously tried another one). However, for both of them I have an identical error when I try to import both of them in a jupyter notebook:

import lightgbm as lgb

I get:

ModuleNotFoundError: No module named 'lightgbm'

and I get an identical error with CatBoost as well.

Any ideas? Thank you!


Solution

  • 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.

    Since pip reports both packages installed in your "main" environment (i.e. the one coming up when you simply open a Windows command prompt), what you should do is open Jupyter from the command prompt, as

    jupyter notebook
    

    and your packages will indeed be available for importing, as we confirmed indeed.