0

Using PyCaret for the first time. Installed Anacoda using command line and then install PyCaret inside the Jupyter Notebook.

PyCaret installed is successful because this following code works:

from pycaret.datasets import get_data
jewellery = get_data('jewellery') 

But when using following code:

from pycaret.clustering import *

The following error comes:


-
OSError                                   Traceback (most recent call last)
/var/folders/2s/mwp2zlp50sb75l3zpcq67szw0000gp/T/ipykernel_16163/1576494110.py in <module>
----> 1 from pycaret.clustering import *
      2 exp_name = setup(data = jewellery)

~/anaconda3/lib/python3.9/site-packages/pycaret/clustering.py in <module>
     14 import ipywidgets as ipw
     15 from typing import List, Tuple, Any, Union, Optional, Dict
---> 16 import pycaret.internal.tabular
     17 
     18 from pycaret.internal.tabular import MLUsecase

~/anaconda3/lib/python3.9/site-packages/pycaret/internal/tabular.py in <module>
     46 import pycaret.containers.models.clustering
     47 import pycaret.containers.models.anomaly
---> 48 import pycaret.internal.preprocess
     49 import pandas as pd
     50 import numpy as np

~/anaconda3/lib/python3.9/site-packages/pycaret/internal/preprocess.py in <module>
     32 from sklearn.ensemble import RandomForestClassifier as rfc
     33 from sklearn.ensemble import RandomForestRegressor as rfr
---> 34 from lightgbm import LGBMClassifier as lgbmc
     35 from lightgbm import LGBMRegressor as lgbmr
     36 import sys

~/anaconda3/lib/python3.9/site-packages/lightgbm/__init__.py in <module>
      6 from pathlib import Path
      7 
----> 8 from .basic import Booster, Dataset, Sequence, register_logger
      9 from .callback import early_stopping, log_evaluation, print_evaluation, record_evaluation, reset_parameter
     10 from .engine import CVBooster, cv, train

~/anaconda3/lib/python3.9/site-packages/lightgbm/basic.py in <module>
    108 
    109 
--> 110 _LIB = _load_lib()
    111 
    112 

~/anaconda3/lib/python3.9/site-packages/lightgbm/basic.py in _load_lib()
     99     if len(lib_path) == 0:
    100         return None
--> 101     lib = ctypes.cdll.LoadLibrary(lib_path[0])
    102     lib.LGBM_GetLastError.restype = ctypes.c_char_p
    103     callback = ctypes.CFUNCTYPE(None, ctypes.c_char_p)

~/anaconda3/lib/python3.9/ctypes/__init__.py in LoadLibrary(self, name)
    458 
    459     def LoadLibrary(self, name):
--> 460         return self._dlltype(name)
    461 
    462     __class_getitem__ = classmethod(_types.GenericAlias)

~/anaconda3/lib/python3.9/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    380 
    381         if handle is None:
--> 382             self._handle = _dlopen(self._name, mode)
    383         else:
    384             self._handle = handle

OSError: dlopen(/Users/sparsh/anaconda3/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so, 0x0006): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
  Referenced from: /Users/sparsh/anaconda3/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so
  Reason: tried: '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)

Any help would be greatly appreciated?

1 Answers1

1

If your os is Mac.

brew install libomp 

solves the problem.

paul kim
  • 111
  • 5
  • Yes. I also saw this solution here: https://pycaret.org/install2/ Could you please explain where do I run this command? In the terminal OR Jupyter notebook? – Sparsh Chugh Dec 20 '21 at 15:42
  • Ofcoure in terminal. check this out https://brew.sh/ – paul kim Dec 20 '21 at 22:59
  • Done all the steps. Issue still remains the same – Sparsh Chugh Dec 21 '21 at 13:01
  • Do you use virtualenv for pycaret? – paul kim Dec 21 '21 at 13:49
  • Let me check. I met same issue like u. First is i didn't brew install libomp. Second is i didn't use virtual env. You seems like using anaconda3 with out virtualenv. check this out ! you need use virtualenv for your PyCaret because PyCaret have many dependencies . https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html After you setup virtualenv, install PyCaret at first. – paul kim Dec 21 '21 at 13:54
  • ✅ Virtual Environment ✅ CMake ✅ OpenMP ✅ libomp ✅ lightgbm ❌ Classification: from pycaret.classification import * ❌ Regression: from pycaret.regression import * ❌ Clustering: from pycaret.clustering import * ❌ Anomaly Detection: from pycaret.anomaly import * ✅ Natural Language Processing: from pycaret.nlp import * ✅ Association Rule Mining: from pycaret.arules import * – Sparsh Chugh Dec 21 '21 at 14:21