LSH icon indicating copy to clipboard operation
LSH copied to clipboard

Unable to install in Python3

Open prabalbansal opened this issue 5 years ago • 6 comments

/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:241:15: note: 'curexc_traceback' declared here PyObject *curexc_traceback; ^ lsh/cMinhash.cpp:19391:13: error: no member named 'exc_type' in '_ts' tstate->exc_type = *type; ~~~~~~ ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 1 warning and 20 errors generated.

It works for Python2.7 but not able to install in Python3.7.

prabalbansal avatar Jan 10 '20 10:01 prabalbansal

i made some changes locally to get it to work in python 3.7. see if this helps.

diff --git a/lsh/cMinhash.cpp b/lsh/cMinhash.cpp
index db59396..bb5e777 100644
--- a/lsh/cMinhash.cpp
+++ b/lsh/cMinhash.cpp
@@ -19289,21 +19289,21 @@ return_ne:
 /* SaveResetException */
       #if CYTHON_COMPILING_IN_CPYTHON
 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
-    *type = tstate->exc_type;
-    *value = tstate->exc_value;
-    *tb = tstate->exc_traceback;
+    *type = tstate->curexc_type;
+    *value = tstate->curexc_value;
+    *tb = tstate->curexc_traceback;
     Py_XINCREF(*type);
     Py_XINCREF(*value);
     Py_XINCREF(*tb);
 }
 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
     PyObject *tmp_type, *tmp_value, *tmp_tb;
-    tmp_type = tstate->exc_type;
-    tmp_value = tstate->exc_value;
-    tmp_tb = tstate->exc_traceback;
-    tstate->exc_type = type;
-    tstate->exc_value = value;
-    tstate->exc_traceback = tb;
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = type;
+    tstate->curexc_value = value;
+    tstate->curexc_traceback = tb;
     Py_XDECREF(tmp_type);
     Py_XDECREF(tmp_value);
     Py_XDECREF(tmp_tb);
@@ -19358,12 +19358,12 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
     *value = local_value;
     *tb = local_tb;
 #if CYTHON_COMPILING_IN_CPYTHON
-    tmp_type = tstate->exc_type;
-    tmp_value = tstate->exc_value;
-    tmp_tb = tstate->exc_traceback;
-    tstate->exc_type = local_type;
-    tstate->exc_value = local_value;
-    tstate->exc_traceback = local_tb;
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = local_type;
+    tstate->curexc_value = local_value;
+    tstate->curexc_traceback = local_tb;
     Py_XDECREF(tmp_type);
     Py_XDECREF(tmp_value);
     Py_XDECREF(tmp_tb);
@@ -19385,12 +19385,12 @@ bad:
         #if CYTHON_COMPILING_IN_CPYTHON
 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
     PyObject *tmp_type, *tmp_value, *tmp_tb;
-    tmp_type = tstate->exc_type;
-    tmp_value = tstate->exc_value;
-    tmp_tb = tstate->exc_traceback;
-    tstate->exc_type = *type;
-    tstate->exc_value = *value;
-    tstate->exc_traceback = *tb;
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = *type;
+    tstate->curexc_value = *value;
+    tstate->curexc_traceback = *tb;
     *type = tmp_type;
     *value = tmp_value;
     *tb = tmp_tb;

paralax avatar May 18 '20 19:05 paralax

changing

USE_CYTHON = True

in setup.py also works

noamwies avatar Aug 31 '20 06:08 noamwies

changing

USE_CYTHON = True

in setup.py also works

This solutions works for python 3.7 only if you rebuild lsh/cMinhash.cpp file. On a fresh git clone, that might not happen. So we need to add force=True to the cythonize call.

extensions = cythonize(extensions, force=True)

nonatofabio avatar Nov 09 '20 20:11 nonatofabio

I forked this lib with fixes for Python3 included: https://github.com/boriswinner/LSH

!rm -rf LSH && git clone https://github.com/boriswinner/LSH && cd LSH && python setup.py install import LSH Works in Colab

boriswinner avatar Dec 01 '21 20:12 boriswinner

I also meet same problem. https://github.com/boriswinner/LSH shows ModuleNotFoundError: No module named 'Cython'

LukeLIN-web avatar Mar 07 '24 16:03 LukeLIN-web