chianti-atomic / ChiantiPy

ChiantiPy is a python package to calculate the radiative properties of astrophysical plasmas based on the CHIANTI atomic database
62 stars 33 forks source link

Unable to import ChiantiPy.core as ch #460

Closed NyankoSong closed 2 months ago

NyankoSong commented 2 months ago

Hello! I cannot import ChiantiPy.core in my conda environment and I have no idea why. Here are some logs that might be useful. Any help would be greatly appreciated!

(spcphys) ps@ps-workstation:~$ echo $XUVTOP
/opt/miniconda3/EXTRA_FILES/CHIANTI_database
(spcphys) ps@ps-workstation:~$ cat $XUVTOP/VERSION
10.1
(spcphys) ps@ps-workstation:~$ ipython
Python 3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:53:32) [GCC 12.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.22.2 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import ChiantiPy
 ChiantiPy version 0.15.0

In [2]: import ChiantiPy.core as ch
 found PyQt5 widgets
 using PyQt5 widgets
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 1
----> 1 import ChiantiPy.core as ch

File /opt/miniconda3/envs/spcphys/lib/python3.11/site-packages/ChiantiPy/core/__init__.py:8
      1 """
      2 chianti.core - contains the main classes for ChiantiPy users.
      3
   (...)
      6
      7 """
----> 8 from .Spectrum import spectrum
      9 from .Bunch import bunch
     10 from .Mspectrum import mspectrum

File /opt/miniconda3/envs/spcphys/lib/python3.11/site-packages/ChiantiPy/core/Spectrum.py:5
      3 import numpy as np
      4 import ChiantiPy
----> 5 import ChiantiPy.tools.data as chdata
      6 import ChiantiPy.tools.constants as const
      7 import ChiantiPy.tools.filters as chfilters

File /opt/miniconda3/envs/spcphys/lib/python3.11/site-packages/ChiantiPy/tools/data.py:58
     56 for fname in glob.glob(os.path.join(Xuvtop, 'abundance', '*.abund')):
     57     AbundanceList.append(os.path.splitext(os.path.basename(fname))[0])
---> 58 Abundance = {abundance: chio.abundanceRead(abundancename=abundance)
     59              for abundance in AbundanceList}
     60 GrndLevels = chio.grndLevelsRead()
     61 Verner_info = chio.vernerRead()

File /opt/miniconda3/envs/spcphys/lib/python3.11/site-packages/ChiantiPy/tools/data.py:58, in <dictcomp>(.0)
     56 for fname in glob.glob(os.path.join(Xuvtop, 'abundance', '*.abund')):
     57     AbundanceList.append(os.path.splitext(os.path.basename(fname))[0])
---> 58 Abundance = {abundance: chio.abundanceRead(abundancename=abundance)
     59              for abundance in AbundanceList}
     60 GrndLevels = chio.grndLevelsRead()
     61 Verner_info = chio.vernerRead()

File /opt/miniconda3/envs/spcphys/lib/python3.11/site-packages/ChiantiPy/tools/io.py:75, in abundanceRead(abundancename, verbose)
     73 nlines -= 1
     74 for line in range(nlines):
---> 75     z,ab,element = s1[line].split()
     76     abundance[int(z)-1] = float(ab)
     77 gz = np.nonzero(abundance)

ValueError: too many values to unpack (expected 3)
kdere commented 2 months ago

First I see the you are not using the latest version of ChiantiPy which is 0.15.1

Someone else noticed before that Conda was not using the latest version but I don't know if that is still the case

There was an update to abundanceRead in order to read some of the new abundance files in CHIANTI version 10.1 and I see that you are using the latest CHIANTI version

I would try updating to the lastest ChiantiPy version

hope this helps

NyankoSong commented 2 months ago

First I see the you are not using the latest version of ChiantiPy which is 0.15.1

Someone else noticed before that Conda was not using the latest version but I don't know if that is still the case

Yes, conda-forge is not providing the latest 0.15.1 version... I didn't notice this before, since I prefer not to use pip as it might make conda environments harder to pack and immigrate to another PC.

There was an update to abundanceRead in order to read some of the new abundance files in CHIANTI version 10.1 and I see that you are using the latest CHIANTI version

I would try updating to the lastest ChiantiPy version

I tried to upgrade ChiantiPy to 0.15.1, and this problem just disappeared.

hope this helps

This helps a lot, thanks for your kind reply!