keflavich / pyradex

Python interface to RADEX
BSD 3-Clause "New" or "Revised" License
18 stars 12 forks source link

Import error #29

Closed snlongmore closed 4 years ago

snlongmore commented 4 years ago

Hi Adam, Sorry to bug you with this, but after I installed pyradex (which seemed to work) I get the following error when I try to import:

> In [1]: import pyradex
> ---------------------------------------------------------------------------
> ImportError                               Traceback (most recent call last)
> <ipython-input-1-2cab900d2f16> in <module>
> ----> 1 import pyradex
> 
> pyradex/pyradex/pyradex/__init__.py in <module>
>       5 from . import utils
>       6 from . import despotic_interface
> ----> 7 from . import radex
>       8 from . import synthspec
> 
> pyradex/pyradex/radex/__init__.py in <module>
> ----> 1 from . import radex
> 
> ImportError: dynamic module does not define module export function (PyInit_radex)

Here are details of my system:

> $ python -c "import sys, astropy, numpy; print(sys.version); print(numpy.version,astropy.version)"
> 3.7.5 (default, Oct 25 2019, 10:52:18)
> [Clang 4.0.1 (tags/RELEASE_401/final)]
> <module 'numpy.version' from '/Users/stevenlongmore/opt/anaconda2/envs/py3/lib/python3.7/site-packages/numpy/version.py'> <module 'astropy.version' from '/Users/stevenlongmore/opt/anaconda2/envs/py3/lib/python3.7/site-packages/astropy/version.py'>

I'm not sure if this may be related to issue #28.

keflavich commented 4 years ago

I suspect it's not related to #28.

My first guess is that maybe you don't have the right compilers. If you do which gfortran, what comes up?

I suggest trying to star from an anaconda-python session. Something like:

conda create -n pyradex matplotlib astropy ipython

then install pyradex and see if it works.

However... now that I say that... I see you are on an anaconda build... so I don't know! I'm just guessing as I've never seen this error.

snlongmore commented 4 years ago

Thanks, it was indeed the gfortran compiler. Good catch!

Turns out I have a system wide gfortran version located here /usr/local/bin/gfortran, but the conda environment I was using had a different gfortran located here /Users/stevenlongmore/opt/anaconda2/envs/py3/bin/gfortran.

I created a new conda environment as you suggested, and made sure it linked to /usr/local/bin/gfortran, and pyradex is now working fine.

Thanks again matey!