Lightgbm OSError, Library not loaded

前端 未结 7 889
抹茶落季
抹茶落季 2021-02-13 03:03

If I simply do:

import lightgbm as lgb

I\'m getting

python script.py 
Traceback (most recent call last):
File \"script.py\", li         


        
相关标签:
7条回答
  • 2021-02-13 03:17

    Same error, different source: seems like I had the gcc 8 version installed, and it needs gcc 7.

    It worked by switching it back to last gcc 7 version:

    brew switch gcc 7.3.0_1
    
    0 讨论(0)
  • 2021-02-13 03:18

    On MacOS High Sierra with MacPorts installed, I did the following:

    1. Install clang-5.0 using MacPorts
    2. Inside the /build directory, run cmake -DCMAKE_CXX_COMPILER=clang++-mp-5.0 -DCMAKE_C_COMPILER=clang-mp-5.0 ..
    3. To build the python package, go to /python_package directory and modify the setup.py script. You need to modify the function compile_cpp() at the very end that checks the case for other OS (including Mac). Before the silent_call(...), add the following two lines: cmake_cmd.append("-DCMAKE_CXX_COMPILER=clang++-mp-5.0") cmake_cmd.append("-DCMAKE_C_COMPILER=clang-mp-5.0")
    4. Run sudo python setup.py install. Enjoy
    0 讨论(0)
  • 2021-02-13 03:22

    I used this command generated from PyCharm and it worked for me.

    conda install -p { < =replace with USER_HOME_DIR>}/anaconda3 lightgbm -y

    Note : i tried Brew and pip install but they didn't work for me as Azure ML studio already downloaded other versions of LightGBM that were causing conflict in upgrading to correct packages.

    0 讨论(0)
  • 2021-02-13 03:27

    For users with macports, replace the beginning of the brew solution with:

    1. port install gcc7 cmake
    2. export CXX=g++-mp-7 CC=gcc-mp-7
    0 讨论(0)
  • 2021-02-13 03:30

    All the above answers didn't work for me. On Mac, if I installed the libomp using brew fixed the problem: Refer: link

    brew install libomp
    
    0 讨论(0)
  • 2021-02-13 03:36

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

    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  
    

    Then install:

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

    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.

    0 讨论(0)
提交回复
热议问题