Unable to find `libcpfapack.so`
Closed this issue · 6 comments
I cannot import the C bindings. I have the latest C++ build tools installed and installed the package via conda as suggested. Here is the error message
FileNotFoundError: Could not find module 'libcpfapack.so' (or one of its dependencies). Try using the full path with constructor syntax.
I'd prefer to clone and manually install the repo regardless, can I generate this library myself?
Are you sure you are using the correct conda environment? Perhaps your PATH is incorrect.
Anyhow, to build yourself, you could look at https://github.com/conda-forge/pfapack-feedstock/blob/main/recipe/build.sh for inspiration.
Can you provide any insight to what I might need in my PATH? I am installing into a virtual environment in a fresh installation of miniconda, and it fails. Additional instructions would be greatly appreciated.
I am convinced that the conda installation does not include C-bindings. I have tried generating them myself using the original c_interface library on Wimmer's personal website, however its been 6+ years since working with C and I've been unable to produce a working library.
libcpfapack.so does not exist anywhere in my miniconda3 directory, nor do any other C source files needed to generate it. Any insight would be greatly appreciated.
If I download the file from https://anaconda.org/conda-forge/pfapack/files I do see libcpfapack.so
.
I tried:
conda install -y pfapack
then python
:
import numpy as np
import numpy.linalg
import numpy.matlib
from pfapack.ctypes import pfaffian as cpfaffian
from pfapack import pfaffian as pf # noqa isort:skip
for method in ("P", "H"):
# first real matrices
A = numpy.matlib.rand(100, 100)
A = A - A.T
pf_a = cpfaffian(A, uplo="L", method=method)
pf_a2 = cpfaffian(A, uplo="L", avoid_overflow=True, method=method)
np.testing.assert_almost_equal(pf_a / pf_a2, 1)
np.testing.assert_almost_equal(pf_a / pf.pfaffian(A), 1)
# then complex matrices
A = numpy.matlib.rand(100, 100) + 1.0j * numpy.matlib.rand(100, 100)
A = A - A.T
pf_a = cpfaffian(A, uplo="L", method=method)
pf_a2 = cpfaffian(A, uplo="L", avoid_overflow=True, method=method)
np.testing.assert_almost_equal(pf_a / pf_a2, 1)
np.testing.assert_almost_equal(pf_a / pf.pfaffian(A), 1)
And this seems to just work fine for me.
Unfortunately, I currently have no time to debug your problem.
I'm not familiar with conda packaging or C, but is libcpfapack.so
only available for linux and OSX, and not for Windows?
It looks like https://github.com/conda-forge/pfapack-feedstock/blob/main/recipe/bld.bat doesn't call any C compiler, and no .so
files are included in the Windows builds in https://anaconda.org/conda-forge/pfapack/files
I just released a new version 1.0.0 that should include the libcpfapack.so file even with the PyPI install.
Although I already noticed a problem, so I will release 1.0.1 ASAP where the C code is properly tested on all 3 OSes.