相关文章推荐
一身肌肉的杯子  ·  ModuleNotFoundError: ...·  1 年前    · 
坚韧的板栗  ·  解决 anaconda 报错 ...·  1 年前    · 
憨厚的黄瓜  ·  python - Why ...·  1 年前    · 
谦和的猕猴桃  ·  Spark3.2 VS ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

My OS is Ubuntu, and I've followed the official installation guide to install lightgbm. However, when I import it, this error is raised:

ImportError: No module named lightgbm

How can I solve this?

Do I also need to go to /python-package folder to run setup.py after running those linux commandlines?

@lmiguelvargasf The same as the official guide:git clone --recursive github.com/Microsoft/LightGBM ; cd LightGBM mkdir build ; cd build cmake .. make -j dlwlrma May 27, 2017 at 3:45 are you getting this error while installing? I mean share the code when you import this library. lmiguelvargasf May 27, 2017 at 3:46

For Windows users, VC runtime <https://go.microsoft.com/fwlink/?LinkId=746572> is needed if Visual Studio (2015 or 2017) is not installed.

Install wheel <http://pythonwheels.com> via pip install wheel first. After that download the wheel file and install from it:

pip install lightgbm

The following should do the trick:

export PATH=/usr/local/bin/anaconda3/bin${PATH:+:${PATH}}
PYTHONPATH=$PYTHONPATH:/usr/local/bin/anaconda3/lib/python3.6/site-packages

Note that you might need to change the paths if you are using a different Python version.

Problem:

After successfull install of lightgbm, I was getting the error ImportError: No module named 'lightgbm' (in Jupyter Notebook on Google Cloud's Notebook Instance in AI Platform project).

Issue:

Realized that the install of lightgbm was in Python 2.7 even when the notebook was running in Python 3 (path: './.local/lib/python2.7/site-packages').

Solution:

The error was gone after the Jupyter Notebook was set to run on Python 2 instead of Python 3.

within Jupyter Notebook cell is: try running

import sys
!{sys.executable} -m pip install lightgbm

With python try, from pypi.org, this line

pip install lightgbm
pip3 install lightgbm

Also, you can try this one if you use anaconda

conda install lightgbm
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.