bbalasub1 / glmnet_python

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

AttributeError: Module 'scipy' has no attribute 'empty' #68

Open yalda1205 opened 6 months ago

yalda1205 commented 6 months ago

Hi, I install the package using these lines: git clone https://github.com/bbalasub1/glmnet_python.git cd glmnet_python python setup.py install

and then try to import the package: import glmnet_python

but there is this error:

{ "name": "AttributeError", "message": "Module 'scipy' has no attribute 'empty'", "stack": "--------------------------------------------------------------------------- KeyError Traceback (most recent call last) File ~/venv_environments/glmnet/lib/python3.11/site-packages/scipy/init.py:137, in getattr(name) 136 try: --> 137 return globals()[name] 138 except KeyError:

KeyError: 'empty'

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last) Cell In[1], line 3 1 import scipy, importlib, pprint, matplotlib.pyplot as plt, warnings 2 from scipy import integrate ----> 3 import glmnet_python 4 from glmnet import glmnet 5 from glmnet import glmnet; from glmnetPlot import glmnetPlot

File ~/venv_environments/glmnet/lib/python3.11/site-packages/glmnet_python/init.py:10 8 from .glmnetPlot import glmnetPlot 9 from .glmnetPrint import glmnetPrint ---> 10 from .glmnetCoef import glmnetCoef 11 from .glmnetPredict import glmnetPredict 12 from .cvglmnet import cvglmnet

File ~/venv_environments/glmnet/lib/python3.11/site-packages/glmnet_python/glmnetCoef.py:72 2 \"\"\" 3 -------------------------------------------------------------------------- 4 glmnetCoef computes coefficients from a \"glmnet\" object. (...) 68 69 \"\"\" 71 import scipy ---> 72 from glmnetPredict import glmnetPredict 74 def glmnetCoef(obj, s = None, exact = False): 76 if s is None:

File ~/venv_environments/glmnet/lib/python3.11/site-packages/glmnet_python/glmnetPredict.py:110 106 import scipy 107 import scipy.interpolate 109 def glmnetPredict(fit,\ --> 110 newx = scipy.empty([0]), \ 111 s = scipy.empty([0]), \ 112 ptype = 'link', \ 113 exact = False, \ 114 offset = scipy.empty([0])): 116 typebase = ['link', 'response', 'coefficients', 'nonzero', 'class'] 117 indxtf = [x.startswith(ptype.lower()) for x in typebase]

File ~/venv_environments/glmnet/lib/python3.11/site-packages/scipy/init.py:139, in getattr(name) 137 return globals()[name] 138 except KeyError: --> 139 raise AttributeError( 140 f\"Module 'scipy' has no attribute '{name}'\" 141 )

AttributeError: Module 'scipy' has no attribute 'empty'" }

Could you please help me how can I solve it?

petomajci commented 6 months ago

I ran into the same problem. Downgrading to scipy 1.11.0 solved it for me (e.g. pip install scipy==1.11.0)