microsoft / LightGBM

A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.
https://lightgbm.readthedocs.io/en/latest/
MIT License
16.74k stars 3.84k forks source link

LightGBM import error #499

Closed llmercury closed 7 years ago

llmercury commented 7 years ago

Environment info

Operating System: Windows 10 Home, 64 bit CPU: Intel i7-7700 GPU: GeForce GTX 1070 C++/Python version: Microsoft Visual Studio Community 2017/ Python 3.5.2 /Anaconda 4.3.1 (64-bit)

My laptop has 2 hard drives, C: and D:.

I followed the installation instruction at: https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#windows-2

This has GPU support. For D:\local\boost_1_64_0\ and D:\local\boost_1_64_0\lib64-msvc-14.0, the location of the Boost binaries, I set them to the system environment variables BOOST_ROOT and BOOST_LIBRARYDIR. No errors during installation. After installation, I checked it by "conda list lightgbm", it shows lightgbm 0.1. It appeared fine.

However, when I imported the lightgbm in Jupyter Notebook, I got Error messages:

Error Message:


OSError Traceback (most recent call last)

in () ----> 1 import lightgbm as lgb D:\Program_Files\Anaconda3\envs\py35\lib\site-packages\lightgbm-0.1-py3.5.egg\lightgbm\__init__.py in () 7 from __future__ import absolute_import 8 ----> 9 from .basic import Booster, Dataset 10 from .callback import (early_stopping, print_evaluation, record_evaluation, 11 reset_parameter) D:\Program_Files\Anaconda3\envs\py35\lib\site-packages\lightgbm-0.1-py3.5.egg\lightgbm\basic.py in () 29 30 ---> 31 _LIB = _load_lib() 32 33 D:\Program_Files\Anaconda3\envs\py35\lib\site-packages\lightgbm-0.1-py3.5.egg\lightgbm\basic.py in _load_lib() 24 if len(lib_path) == 0: 25 return None ---> 26 lib = ctypes.cdll.LoadLibrary(lib_path[0]) 27 lib.LGBM_GetLastError.restype = ctypes.c_char_p 28 return lib D:\Program_Files\Anaconda3\envs\py35\lib\ctypes\__init__.py in LoadLibrary(self, name) 423 424 def LoadLibrary(self, name): --> 425 return self._dlltype(name) 426 427 cdll = LibraryLoader(CDLL) D:\Program_Files\Anaconda3\envs\py35\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error) 345 346 if handle is None: --> 347 self._handle = _dlopen(self._name, mode) 348 else: 349 self._handle = handle OSError: [WinError 126] The specified module could not be found Please help!
guolinke commented 7 years ago

@llmercury

can you add this line: print(lib_path) before lib = ctypes.cdll.LoadLibrary(lib_path[0]) in the file D:\Program_Files\Anaconda3\envs\py35\lib\site-packages\lightgbm-0.1-py3.5.egg\lightgbm\basic.py ? then run it again ?

llmercury commented 7 years ago

I added print(lib_path) and above the same "OSError Traceback" I got the lib_path:

['D:\Program_Files\Anaconda3\envs\py35\lib\site-packages\lightgbm-0.1-py3.5.egg\lightgbm\lib_lightgbm.dll']

And I checked the "lightgbm" folder and lib_lightgbm.dll is indeed in the folder.

guolinke commented 7 years ago

can you try the latest commit ?

llmercury commented 7 years ago

I used "git clone --recursive https://github.com/Microsoft/LightGBM" Isn't it the latest version? If not, how to get the latest version?

guolinke commented 7 years ago

@llmercury I just commit a fix for this. So you can re-clone the code.

llmercury commented 7 years ago

I re-cloned it. During building, error happened:

CMake Error in CMakeLists.txt: A logical block opening on the line

D:/PythonModules/LightGBM/CMakeLists.txt:38 (if)

is not closed.

Maybe adding endif() on line 45 or 46?

guolinke commented 7 years ago

@llmercury sorry, forgot endif. just push a new fix.

llmercury commented 7 years ago

Awesome. Problem solved! Thank a lot! @guolinke

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.