Title: ImportError: DLL load failed on Windows - Missing delvewheel patch for vector_search/lib directory
Description:
When importing tiledb.vector_search on Windows, the following error occurs:
ImportError: DLL load failed while importing _tiledbvspy: The specified module could not be found.
Environment:
- OS: Windows
- Python: 3.x (virtual environment)
- Package:
tiledb-vector-search (latest version from PyPI)
Root Cause:
The _tiledbvspy.pyd extension module depends on tiledb.dll, which is located in tiledb/vector_search/lib/. However, this directory is not added to Windows' DLL search path during import, causing the DLL load failure.
While the main tiledb package includes a delvewheel patch in tiledb/__init__.py that adds tiledb.libs to the DLL search path:
def _delvewheel_patch_1_11_2():
import os
if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'tiledb.libs'))):
os.add_dll_directory(libs_dir)
The tiledb-vector-search package is missing a similar patch for its own lib subdirectory in tiledb/vector_search/__init__.py.
Proposed Solution:
Add a delvewheel patch to the top of tiledb/vector_search/__init__.py (before line 4 where from . import utils occurs):
# start delvewheel patch
def _delvewheel_init_patch_tiledb_vector_search():
import os
libs_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))
if os.path.isdir(libs_dir):
os.add_dll_directory(libs_dir)
_delvewheel_init_patch_tiledb_vector_search()
del _delvewheel_init_patch_tiledb_vector_search
# end delvewheel patch
from . import utils
# ... rest of existing code
Workaround:
Users can temporarily work around this issue by adding the following code before importing tiledb.vector_search:
import os
import sys
import ctypes
import tiledb
# Get site-packages path
venv_root = os.path.dirname(os.path.dirname(sys.executable))
site_packages = os.path.join(venv_root, 'Lib', 'site-packages')
# Add vector_search/lib to DLL search path
vector_search_lib = os.path.join(site_packages, 'tiledb', 'vector_search', 'lib')
if os.path.isdir(vector_search_lib):
os.add_dll_directory(vector_search_lib)
# Preload tiledb.dll
tiledb_dll = os.path.join(vector_search_lib, 'tiledb.dll')
if os.path.exists(tiledb_dll):
ctypes.CDLL(tiledb_dll)
import tiledb.vector_search as vs
Additional Context:
This issue affects all Windows users installing from PyPI. The delvewheel patch should be automatically injected during the wheel building process, or manually added to the source code.
Title:
ImportError: DLL load failedon Windows - Missing delvewheel patch for vector_search/lib directoryDescription:
When importing
tiledb.vector_searchon Windows, the following error occurs:Environment:
tiledb-vector-search(latest version from PyPI)Root Cause:
The
_tiledbvspy.pydextension module depends ontiledb.dll, which is located intiledb/vector_search/lib/. However, this directory is not added to Windows' DLL search path during import, causing the DLL load failure.While the main
tiledbpackage includes a delvewheel patch intiledb/__init__.pythat addstiledb.libsto the DLL search path:The
tiledb-vector-searchpackage is missing a similar patch for its ownlibsubdirectory intiledb/vector_search/__init__.py.Proposed Solution:
Add a delvewheel patch to the top of
tiledb/vector_search/__init__.py(before line 4 wherefrom . import utilsoccurs):Workaround:
Users can temporarily work around this issue by adding the following code before importing
tiledb.vector_search:Additional Context:
This issue affects all Windows users installing from PyPI. The delvewheel patch should be automatically injected during the wheel building process, or manually added to the source code.