Why ImportError: No module named lightgbm
Question:
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?
Answers:
Besides running those linux command lines. I also need to go to /python-package
then run ‘python setup.py install’.
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.
Thank you for above question and answers, had a similar issue.
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.
I had the same problem, and solved running the installation directly on the notebook
!pip install lightgbm
conda install -c conda-forge lightgbm
solved the problem for me
you need just run in a notebook cell before importing
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
or
pip3 install lightgbm
Also, you can try this one if you use anaconda
conda install lightgbm
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?
Besides running those linux command lines. I also need to go to /python-package
then run ‘python setup.py install’.
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.
Thank you for above question and answers, had a similar issue.
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.
I had the same problem, and solved running the installation directly on the notebook
!pip install lightgbm
conda install -c conda-forge lightgbm
solved the problem for me
you need just run in a notebook cell before importing
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
or
pip3 install lightgbm
Also, you can try this one if you use anaconda
conda install lightgbm