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?
–
–
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.