nmslib / hnswlib

Header-only C++/python library for fast approximate nearest neighbors
https://github.com/nmslib/hnswlib
Apache License 2.0
4.12k stars 609 forks source link

cannot import binding error #464

Open jth3galv opened 1 year ago

jth3galv commented 1 year ago

I have tried installing with pip and from source (even recompiling)

C code compile and works but I cannot import hnswlib library in python (3.9). I get:

ImportError: /home/giulio/anaconda3/lib/python3.9/site-packages/hnswlib.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZNSt15__exception_ptr13exception_ptr10_M_releaseEv

yurymalkov commented 1 year ago

I looks like a conda environment issue, this is discussed https://github.com/pybind/pybind11/issues/3623

wjtan99 commented 7 months ago

I had the same issue with Python 3.7.4 in Ubuntu 22.04. I tried both pip install hnswlib, and pip install . from source code. I also tried older version 0.6.2, 0.5.1, 0.4.0. The error is "undefined symbol: _ZNSt15__exception_ptr13exception_ptr10_M_releaseEv"

I looked at https://github.com/pybind/pybind11/issues/3623, the solution is to use G++ 9 or 10, but your code requires a C++ 11.0.

I tried conda install -c conda-forge hnswlib on different versions, the error becomes "CondaValueError: Malformed version string '~': invalid character(s)."

AlexYoung757 commented 2 months ago

i have same issue,solved by: export LD_PRELOAD=/your path/hnswlib.xxx.so: