Lightgbm OSError,未加载库 [英] Lightgbm OSError, Library not loaded

查看:218
本文介绍了Lightgbm OSError,未加载库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我只是这样做:

import lightgbm as lgb

我要

python script.py 
Traceback (most recent call last):
File "script.py", line 4, in <module>
import lightgbm as lgb
File "/usr/local/lib/python2.7/site-packages/lightgbm/__init__.py", line 8, in <module>
from .basic import Booster, Dataset
File "/usr/local/lib/python2.7/site-packages/lightgbm/basic.py", line 31, in <module>
_LIB = _load_lib()
File "/usr/local/lib/python2.7/site-packages/lightgbm/basic.py", line 26, in _load_lib
lib = ctypes.cdll.LoadLibrary(lib_path[0])
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 440, in LoadLibrary
return self._dlltype(name)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 362, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/python2.7/site-packages/lightgbm/lib_lightgbm.so, 6): Library not loaded: /usr/local/opt/gcc/lib/gcc/7/libgomp.1.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/lightgbm/lib_lightgbm.so
Reason: image not found

我似乎已正确安装所有东西:

I seem to have everything installed correct:

python -m pip install lightgbm
Requirement already satisfied: lightgbm in /usr/local/lib/python2.7/site-packages
Requirement already satisfied: wheel in /usr/local/lib/python2.7/site-packages (from lightgbm)
Requirement already satisfied: scikit-learn in /usr/local/lib/python2.7/site-packages (from lightgbm)
Requirement already satisfied: scipy in /usr/local/lib/python2.7/site-packages (from lightgbm)
Requirement already satisfied: numpy in /usr/local/lib/python2.7/site-packages (from lightgbm)

我的GCC文件夹中确实有6个文件夹.我是否需要安装其他版本的GCC才能正常工作?

I do have a 6 folder in my GCC folder. Should I need to install another version of GCC for this to work?

推荐答案

我在这里 LightGBM
答案和评论可能会对您有所帮助.

I find a similar problem here LightGBM
The answer and comment may help you.

在Mac中构建LightGBM:

Build LightGBM in Mac:

brew install cmake  
brew install gcc --without-multilib  
git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM  
mkdir build ; cd build  
cmake ..   
make -j  

然后安装:

cd ../python-packages  
sudo python setup.py install --precompile

如@ecodan所述,您可能需要强制Mac使用GCC和G ++而不是默认编译器.因此,与其尝试使用cmake ..进行构建,不如尝试:

As stated by @ecodan, you might need to force Mac to use GCC and G++ instead of the default compiler. So instead of building with cmake .., try:

cmake -DCMAKE_C_COMPILER=/usr/local/Cellar/gcc/6.1.0/bin/gcc-6 -DCMAKE_CXX_COMPILER=/usr/local/Cellar/gcc/6.1.0/bin/g++-6 ..

调整版本以匹配您的版本.

ajusting the versions to match yours.

这篇关于Lightgbm OSError,未加载库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆