PyCaret 的 OSError Traceback(最近一次调用最后一次)
Posted
技术标签:
【中文标题】PyCaret 的 OSError Traceback(最近一次调用最后一次)【英文标题】:OSError Traceback (most recent call last) for PyCaret 【发布时间】:2022-01-22 04:53:31 【问题描述】:第一次使用 PyCaret。 使用命令行安装 Anacoda,然后在 Jupyter Notebook 中安装 PyCaret。
PyCaret 安装成功,因为以下代码有效:
from pycaret.datasets import get_data
jewellery = get_data('jewellery')
但是当使用以下代码时:
from pycaret.clustering import *
出现以下错误:
-
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)
任何帮助将不胜感激?
【问题讨论】:
【参考方案1】:如果你的操作系统是 Mac。
brew install libomp
解决问题。
【讨论】:
是的。我在这里也看到了这个解决方案:pycaret.org/install2 你能解释一下我在哪里运行这个命令吗?在终端或 Jupyter 笔记本中? Ofcoure 在终端。看看这个brew.sh 完成所有步骤。问题依旧 你在pycaret中使用virtualenv吗? 让我检查一下。我遇到了和你一样的问题。首先是我没有 brew install libomp。其次是我没有使用虚拟环境。您似乎在使用 anaconda3 而没有 virtualenv。看一下这个 !你需要为你的 PyCaret 使用 virtualenv 因为 PyCaret 有很多依赖项。 docs.conda.io/projects/conda/en/latest/user-guide/tasks/… 设置好 virtualenv 后,首先安装 PyCaret。以上是关于PyCaret 的 OSError Traceback(最近一次调用最后一次)的主要内容,如果未能解决你的问题,请参考以下文章
Pycaret.anomaly 库中的 Anomaly_Score 是啥意思?
机器学习建模神器PyCaret已开源!提升效率,几行代码轻松搞定模型