bbalasub1 / glmnet_python

GNU General Public License v3.0
200 stars 95 forks source link

Hard-coded libgfortran #53

Closed david-cortes closed 3 years ago

david-cortes commented 3 years ago

Tried installing the library by running the setup script, but then I get this error when loading it:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-12-9b9ffd42f960> in <module>
      3 from scipy.sparse import csc_matrix
      4 
----> 5 fit = glmnet(x = X.astype(np.float64), y = Y.copy(), family = 'multinomial')

~/anaconda3/lib/python3.7/site-packages/glmnet_python/glmnet.py in glmnet(x, y, family, **options)
    453         fit = lognet(x, is_sparse, irs, pcs, y, weights, offset, parm,
    454                      nobs, nvars, jd, vp, cl, ne, nx, nlam, flmin, ulam,
--> 455                      thresh, isd, intr, maxit, kopt, family)
    456     elif family == 'cox':
    457         # call coxnet

~/anaconda3/lib/python3.7/site-packages/glmnet_python/lognet.py in lognet(x, is_sparse, irs, pcs, y, weights, offset, parm, nobs, nvars, jd, vp, cl, ne, nx, nlam, flmin, ulam, thresh, isd, intr, maxit, kopt, family)
     14 
     15     # load shared fortran library
---> 16     glmlib = loadGlmLib()
     17 
     18     #

~/anaconda3/lib/python3.7/site-packages/glmnet_python/loadGlmLib.py in loadGlmLib()
     22 def loadGlmLib():
     23     if os.name == 'posix':
---> 24         glmlib = ctypes.cdll.LoadLibrary(glmnet_so)
     25         return(glmlib)
     26     elif os.name == 'nt':

~/anaconda3/lib/python3.7/ctypes/__init__.py in LoadLibrary(self, name)
    440 
    441     def LoadLibrary(self, name):
--> 442         return self._dlltype(name)
    443 
    444 cdll = LibraryLoader(CDLL)

~/anaconda3/lib/python3.7/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    362 
    363         if handle is None:
--> 364             self._handle = _dlopen(self._name, mode)
    365         else:
    366             self._handle = handle

OSError: libgfortran.so.3: cannot open shared object file: No such file or directory

For some reason it look for version 3 of libgfortran, which by now is outdated (at least not even available in debian repositories).

Running ldd in the generated .so file shows the following:

        linux-vdso.so.1 (0x00007fff69188000)
        libgfortran.so.5 => /lib/x86_64-linux-gnu/libgfortran.so.5 (0x00007f7442592000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f744244e000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7442289000)
        libquadmath.so.0 => /lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f7442240000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7442226000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f74428ea000)

Setup: debian bullseye, gcc10, python 3.7.

david-cortes commented 3 years ago

Apologies, finally realized that I was loading the version from pip all the time. Building it from source with the setup file works fine.