Vital-Fernandez / lime

Line Measuring library in python
Other
16 stars 6 forks source link

error importing lime #2

Closed albertfxwang closed 1 year ago

albertfxwang commented 1 year ago

Hi Vital,

Thanks so much for bringing this awesome spectral fitting tool to the community. I installed the latest version using pip install lime-stable but when I try to import the package, I got the following error message. Could you please help take a look? Thanks so much!

In [1]: import lime

ImportError Traceback (most recent call last) Cell In [1], line 1 ----> 1 import lime

File ~/local/anaconda3/envs/xwang-jwst/lib/python3.10/site-packages/lime/init.py:38 35 class Error(Exception): 36 """LiMe exception function""" ---> 38 from .treatment import Spectrum, Sample, Cube 39 from .io import 40 from .tools import

File ~/local/anaconda3/envs/xwang-jwst/lib/python3.10/site-packages/lime/treatment.py:8 5 from astropy.io import fits 7 import lime ----> 8 from .tools import LineFinder, UNITS_LATEX_DICT, DISPERSION_UNITS,\ 9 FLUX_DENSITY_UNITS, unit_convertor, define_masks, extract_fluxes, relative_fluxes, compute_line_ratios 11 from .plots import SpectrumFigures, SampleFigures, CubeFigures 12 from .plots_interactive import SpectrumCheck, CubeCheck, SampleCheck

File ~/local/anaconda3/envs/xwang-jwst/lib/python3.10/site-packages/lime/tools.py:19 17 from pathlib import Path 18 from scipy import signal ---> 19 from .io import LiMe_Error 21 _logger = logging.getLogger('LiMe') 23 try:

File ~/local/anaconda3/envs/xwang-jwst/lib/python3.10/site-packages/lime/io.py:24 22 from pathlib import Path 23 from distutils.util import strtobool ---> 24 from collections import Sequence 26 from astropy.io import fits 27 from astropy.table import Table

ImportError: cannot import name 'Sequence' from 'collections' (/Users/wangxin/local/anaconda3/envs/xwang-jwst/lib/python3.10/collections/init.py)

Vital-Fernandez commented 1 year ago

Hello @albertfxwang for your post and sorry for the delay.

I think this error is due to the python version (https://github.com/skorch-dev/skorch/issues/895). Can you try to run this command in your terminal to see if it works?

from collections.abc import Sequence

I can modify to command to make it work for you.

(This week and the next one I am updating the documentation to show the definitive LiMe workflow, Until them I recommend you follow the scripts on the github examples folder to follow the definitive version)

albertfxwang commented 1 year ago

Hi @Vital-Fernandez , I checked that both the following lines of code work for me. python3.10 -c "from collections.abc import Sequence" python3.9 -c "from collections.abc import Sequence" However, when trying to import lime, in Python 3.10 environment, it seems that from collections import Sequence will inflict an error.

Vital-Fernandez commented 1 year ago

Ty @albertfxwang very much for checking. I have modified that import in the 0.9.16 version. You should be able to get it with this command:

pip install lime-stable --upgrade

Please tell me if you have any issue.