Open
Description
Description
Cannot import lightgbm
after installing it with uv
. I am aware uv
might not be supported, but I also tried to install it with pip
inside the virtual environment, and get the same error.
The error I get when trying to import the package is the following:
FileNotFoundError Traceback (most recent call last)
Cell In[2], line 9
6
7
----> 9 import lightgbm as lgb
10
11
File c:\Users\project\.venv\Lib\site-packages\lightgbm\__init__.py:11
7 from pathlib import Path
9 # .basic is intentionally loaded as early as possible, to dlopen() lib_lightgbm.{dll,dylib,so}
10 # and its dependencies as early as possible
---> 11 from .basic import Booster, Dataset, Sequence, register_logger
12 from .callback import EarlyStopException, early_stopping, log_evaluation, record_evaluation, reset_parameter
13 from .engine import CVBooster, cv, train
File c:\Users\project\.venv\Lib\site-packages\lightgbm\basic.py:9
2 """Wrapper for C API of LightGBM."""
4 # This import causes lib_lightgbm.{dll,dylib,so} to be loaded.
5 # It's intentionally done here, as early as possible, to avoid issues like
6 # "libgomp.so.1: cannot allocate memory in static TLS block" on aarch64 Linux.
7 #
8 # For details, see the "cannot allocate memory in static TLS block" entry in docs/FAQ.rst.
----> 9 from .libpath import _LIB # isort: skip
11 import abc
12 import ctypes
File c:\Users\project\.venv\Lib\site-packages\lightgbm\libpath.py:49
47 _LIB = Mock(ctypes.CDLL) # type: ignore
48 else:
---> 49 _LIB = ctypes.cdll.LoadLibrary(_find_lib_path()[0])
File ~\AppData\Roaming\uv\python\cpython-3.13.2-windows-x86_64-none\Lib\ctypes\__init__.py:471, in LibraryLoader.LoadLibrary(self, name)
470 def LoadLibrary(self, name):
--> 471 return self._dlltype(name)
File ~\AppData\Roaming\uv\python\cpython-3.13.2-windows-x86_64-none\Lib\ctypes\__init__.py:390, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
387 self._FuncPtr = _FuncPtr
389 if handle is None:
--> 390 self._handle = _dlopen(self._name, mode)
391 else:
392 self._handle = handle
FileNotFoundError: Could not find module 'c:\Users\project\.venv\Lib\site-packages\lightgbm\bin\lib_lightgbm.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Reproducible example
uv add lightgbm
import lightgbm
Environment info
LightGBM version or commit hash: 4.6.0
Command(s) you used to install LightGBM
uv add lightgbm
# alternatively
python -m pip install lightgbm==4.6.0
Windows 10
Powershell 5.1
Additional Comments
Found related issues: #6079, #5335, #5261, stack overflow question
But I haven't been able to fix this, these issues seem to give solutions for building the library from source.