civisanalytics / python-glmnet

A python port of the glmnet package for fitting generalized linear models via penalized maximum likelihood.
Other
262 stars 59 forks source link

Compilation issue on MacOS #32

Closed JWarmenhoven closed 6 years ago

JWarmenhoven commented 6 years ago

I am running into a number of Fortran compilation issues on MacOS. I followed the installation instructions but when running python setup.py install I get the following warning: (repeated for many lines)

glmnet/src/glmnet/glmnet5.f90:683:72:

       subroutine get_int_parms(sml,eps,big,mnlam,rsqmax,pmin,exmx)          772
                                                                        1
Warning: Line truncated at (1) [-Wline-truncation]

After these, there are warnings about unused labels. At the end it returns an error.

ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
error: Command "/usr/local/bin/gfortran -Wall -g -pie -headerpad_max_install_names build/temp.macosx-10.9-x86_64-3.6/build/src.macosx-10.9-x86_64-3.6/glmnet/_glmnetmodule.o build/temp.macosx-10.9-x86_64-3.6/build/src.macosx-10.9-x86_64-3.6/build/src.macosx-10.9-x86_64-3.6/glmnet/fortranobject.o build/temp.macosx-10.9-x86_64-3.6/glmnet/src/glmnet/glmnet5.o -L/usr/local/Cellar/gcc/6.2.0/lib/gcc/6 -L/usr/local/Cellar/gcc/6.2.0/lib/gcc/6 -L/usr/local/Cellar/gcc/6.2.0/lib/gcc/6/gcc/x86_64-apple-darwin15.6.0/6.2.0 -lgfortran -o build/lib.macosx-10.9-x86_64-3.6/_glmnet.cpython-36m-darwin.so" failed with exit status 1

About about one and a half year ago I succesfully installed python-glmnet. Cannot remember any problems at that time. I am installing in a conda environment. Required packages scipy, numpy, scikit-learn have been installed. Any ideas?

beckermr commented 6 years ago

I don't know about these issues, but a conda package for this would probably be a good idea.

Ignoring compiler warnings is not great practice, but also not crazy. Does the code actually compile? Does it ever throw an error, or do you just get warnings?

JWarmenhoven commented 6 years ago

Indeed, I forgot to mention that the package does not compile. I updated my initial comment.

JWarmenhoven commented 6 years ago

I will try installing with conda-forge: https://github.com/conda-forge/glmnet-feedstock

beckermr commented 6 years ago

Ahhh cool. I did not know that existed!

JWarmenhoven commented 6 years ago

I did not either until today. It installs in the correct conda environment...

$ conda list | grep glm
glmnet                    2.0.0                   np113_0    conda-forge

...but I cannot import the glmnet module.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-35-52c1c0e49750> in <module>()
----> 1 import glmnet as gln

ModuleNotFoundError: No module named 'glmnet'
beckermr commented 6 years ago

I am getting this too. It looks like it is installing the libs to the python 2.7 site packages directory instead of 3.6 for me.

$ ls miniconda3/envs/civis/lib/python2.7/site-packages/
_glmnet.so              glmnet/                 glmnet-2.0.0.dist-info/ 
beckermr commented 6 years ago

I made an issue upstream - https://github.com/conda-forge/glmnet-feedstock/issues/3.

Looking at the conda package, I cannot divine why...

JWarmenhoven commented 6 years ago

Yep...same here. (ends up in python 2.7 site-packages ) Good catch!

beckermr commented 6 years ago

Cool. I put in a fix to the conda package. Hopefully it gets merged soon.

beckermr commented 6 years ago

The new conda forge package has merged. I am closing this. If you still have trouble, please feel free to open an issue here or on the conda forge feedstock!

edoroth commented 3 years ago

I still have an issue importing glmnet. Conda is installing correctly into python 3.8 packages, but I can't understand why it isn't able to import... there is a glymnet.py file inside of the glmnet_python folder which was installed.

import glmnet_python File "/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/glmnet_python/__init__.py", line 12, in <module> from .cvglmnet import cvglmnet File "/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/glmnet_python/cvglmnet.py", line 203, in <module> from glmnet import glmnet ImportError: cannot import name 'glmnet' from 'glmnet' (/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/glmnet/__init__.py)

drealtoni commented 3 years ago

@edoroth were you able to get a solution to this