5

I use pip to install lightgbm on windows,Does it work?

Since I have an error while importing LGBMRegressor. The error shows as below

"cannot import name 'LGBMRegressor'"
McGrady
  • 10,869
  • 13
  • 47
  • 69
Zhixin Zhang
  • 71
  • 1
  • 3
  • 7
  • 2
    pip install lightgbm worked for me (windows 10). Would you mind showing us your code/command? Usually you would import lightgbm and then use LGBMRegressor. Can you try to the example from https://github.com/Microsoft/LightGBM/blob/master/examples/python-guide/simple_example.py , does that work? – ftiaronsem Sep 08 '17 at 18:41
  • to install 1) git clone 2) compile with visual studio 2015 3) python-package\ :python setup.py install, 4) pip install. pip install only install the python wrapper – user3226167 Dec 01 '17 at 06:37

4 Answers4

12

I tried installing it using an anaconda environment and was able to install it successfully.

Open Anaconda prompt and type:

conda install -c conda-forge lightgbm

It will take a few minutes for installation.

Ryan
  • 2,061
  • 17
  • 28
saurabh kumar
  • 506
  • 4
  • 13
3

I am writing an answer as I don't have enough reputation to leave a comment yet. Valid solutions have been offered but I think that some subtleties should be addressed for those that come here and are new(ish) to Python.

There are differences between pip and conda and if I understand it well, one ought to keep using conda as much as possible within their conda environments to avoid running into time-wasting package conflicts. I advise you read this article to get a better grasp on which does what. Myth #2 and #10 are particularly relevant here.

For Lightgbm the obvious solution is to use conda-forge as mentioned above. That is if you are running a conda environment, be it anaconda or miniconda. But you should be aware that for the moment anaconda distribution (AD) and conda-forge (CF) are not 100% compatible, as you can read in this thread. From their own words:

Conda-forge and The Anaconda Distribution are incompatible with each other at present. ...Please pick one or the other for now. CF or AD, never both.

So far it seems not to be a problem for lightbgm though.

Happy coding!

Dany Majard
  • 103
  • 1
  • 9
0

I used this and it worked for me even with Python 3.6

import sys

!{sys.executable} -m pip install lightgbm

Sarab
  • 1
  • 1
0

First I used conda install -c conda-forge lightgbm and I got a permission error so I opened anaconda with administrator privileges. So it worked for me.