yig / PySPQR

Python wrapper for the sparse QR decomposition in SuiteSparseQR.
Creative Commons Zero v1.0 Universal
34 stars 27 forks source link

import sparseqr error #24

Open ivangvozdanovic opened 6 months ago

ivangvozdanovic commented 6 months ago

I have downloaded and installed both SuiteSparse and sparseqr packages, however when I try to import: ( import sparseqr ), I get the following error:

=== Wrapper module not compiled; compiling... generating /usr/local/lib/python3.10/dist-packages/sparseqr/_sparseqr.c setting the current directory to '/usr/local/lib/python3.10/dist-packages' INFO:root:running build_ext INFO:root:building 'sparseqr._sparseqr' extension INFO:root:x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/suitesparse -I/opt/homebrew/include -I/usr/include/python3.10 -c sparseqr/_sparseqr.c -o ./sparseqr/_sparseqr.o

ModuleNotFoundError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/sparseqr/sparseqr.py in 14 try: ---> 15 from ._sparseqr import ffi, lib 16 except ImportError:

ModuleNotFoundError: No module named 'sparseqr._sparseqr' <------------------- This is what I am getting.

During handling of the above exception, another exception occurred:

DistutilsExecError Traceback (most recent call last) 22 frames DistutilsExecError: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

During handling of the above exception, another exception occurred:

CompileError Traceback (most recent call last) CompileError: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

During handling of the above exception, another exception occurred:

VerificationError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/cffi/ffiplatform.py in _build(tmpdir, ext, compiler_verbose, debug) 52 set_threshold(old_level) 53 except (CompileError, LinkError) as e: ---> 54 raise VerificationError('%s: %s' % (e.class.name, e)) 55 # 56 return soname

VerificationError: CompileError: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

Thank you in advance for your help.

yig commented 6 months ago

The same error was reported here: https://github.com/jwyang/faster-rcnn.pytorch/issues/641. The solution for them was to change some paths. Are you able to try that? For them it was:

export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export CPATH=/usr/local/cuda-8.0/include${CPATH:+:${CPATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Another solution is to move the compilation to setup.py (https://cffi.readthedocs.io/en/latest/cdef.html under "For Setuptools (out-of-line only, but works in ABI or API mode; recommended)") and use cibuildwheel https://github.com/pypa/cibuildwheel to have github do all the compilation in advance.

ivangvozdanovic commented 6 months ago

The link says to change paths in the make.sh file. But I do not see that file. I only see _sparseqr.c file. Would that be the one?

yig commented 6 months ago

Those are environment variables. Can you set environment variables for the environment in which your Python is running and importing sparseqr?