Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import astroplan #375

Closed
cristobal-sifon opened this issue Aug 1, 2018 · 9 comments
Closed

cannot import astroplan #375

cristobal-sifon opened this issue Aug 1, 2018 · 9 comments

Comments

@cristobal-sifon
Copy link

I installed astroplan for the first time today, but when I tried to import it I get

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/astropy/io/ascii/core.py in _convert_vals(self, cols)
    944                 try:
--> 945                     converter_func, converter_type = col.converters[0]
    946                     if not issubclass(converter_type, col.type):

IndexError: list index out of range

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-5-418a31c97cf4> in <module>()
----> 1 import astroplan

~/.local/lib/python3.6/site-packages/astroplan-0.5.dev1130-py3.6.egg/astroplan/__init__.py in <module>()
     30     from .periodic import *
     31 
---> 32     get_IERS_A_or_workaround()

~/.local/lib/python3.6/site-packages/astroplan-0.5.dev1130-py3.6.egg/astroplan/utils.py in get_IERS_A_or_workaround()
     55     """
     56     if IERS_A_in_cache():
---> 57         iers.IERS.iers_table = _get_IERS_A_table()
     58     else:
     59         Time._get_delta_ut1_utc = _low_precision_utc_to_ut1

~/.local/lib/python3.6/site-packages/astroplan-0.5.dev1130-py3.6.egg/astroplan/utils.py in _get_IERS_A_table(warn_update)
     89     """
     90     if IERS_A_in_cache():
---> 91         table = iers.IERS_Auto.open()
     92         # Use polar motion flag to identify last observation before predictions
     93         index_of_last_observation = ''.join(table['PolPMFlag_A']).index('IP')

~/anaconda3/lib/python3.6/site-packages/astropy/utils/iers/iers.py in open(cls)
    640             return cls.iers_table
    641 
--> 642         cls.iers_table = cls.read(file=filename)
    643         cls.iers_table.meta['data_url'] = str(conf.iers_auto_url)
    644 

~/anaconda3/lib/python3.6/site-packages/astropy/utils/iers/iers.py in read(cls, file, readme)
    497         # Read in as a regular Table, including possible masked columns.
    498         # Columns will be filled and converted to Quantity in cls.__init__.
--> 499         iers_a = Table.read(file, format='cds', readme=readme)
    500 
    501         # Combine the A and B data for UT1-UTC and PM columns

~/anaconda3/lib/python3.6/site-packages/astropy/table/table.py in read(cls, *args, **kwargs)
   2529         passed through to the underlying data reader (e.g. `~astropy.io.ascii.read`).
   2530         """
-> 2531         out = io_registry.read(cls, *args, **kwargs)
   2532         # For some readers (e.g., ascii.ecsv), the returned `out` class is not
   2533         # guaranteed to be the same as the desired output `cls`.  If so,

~/anaconda3/lib/python3.6/site-packages/astropy/io/registry.py in read(cls, format, *args, **kwargs)
    515 
    516         reader = get_reader(format, cls)
--> 517         data = reader(*args, **kwargs)
    518 
    519         if not isinstance(data, cls):

~/anaconda3/lib/python3.6/site-packages/astropy/io/ascii/connect.py in io_read(format, filename, **kwargs)
     35     from .ui import read
     36     format = re.sub(r'^ascii\.', '', format)
---> 37     return read(filename, format=format, **kwargs)
     38 
     39 

~/anaconda3/lib/python3.6/site-packages/astropy/io/ascii/ui.py in read(table, guess, **kwargs)
    383                                              ' with fast (no guessing)'})
    384         else:
--> 385             dat = reader.read(table)
    386             _read_trace.append({'kwargs': new_kwargs,
    387                                 'Reader': reader.__class__,

~/anaconda3/lib/python3.6/site-packages/astropy/io/ascii/cds.py in read(self, table)
    317                     return table
    318         else:
--> 319             return super().read(table)

~/anaconda3/lib/python3.6/site-packages/astropy/io/ascii/core.py in read(self, table)
   1187         if hasattr(self.header, 'table_meta'):
   1188             self.meta['table'].update(self.header.table_meta)
-> 1189         table = self.outputter(cols, self.meta)
   1190         self.cols = self.header.cols
   1191 

~/anaconda3/lib/python3.6/site-packages/astropy/io/ascii/core.py in __call__(self, cols, meta)
    974         # Sets col.data to numpy array and col.type to io.ascii Type class (e.g.
    975         # FloatType) for each col.
--> 976         self._convert_vals(cols)
    977 
    978         # If there are any values that were filled and tagged with a mask bit then this

~/anaconda3/lib/python3.6/site-packages/astropy/io/ascii/core.py in _convert_vals(self, cols)
    959                     last_err = err
    960                 except IndexError:
--> 961                     raise ValueError('Column {} failed to convert: {}'.format(col.name, last_err))
    962 
    963 

ValueError: Column year failed to convert: invalid literal for int() with base 10: '<h'

I tried import astroplan as well as from astroplan import .... I also ran into this both when pip installing (v0.4) and when cloning and installing from source. This also happens both from the console and in a jupyter notebook. I have python 3.6.4, installed through anaconda

@bmorris3
Copy link
Contributor

bmorris3 commented Aug 1, 2018

Hi @cristobal-sifon! This problem occurs when astroplan tries to read a table that astropy downloads from the internet, and often problems like this occur when there are errors in the table, which happens on occasion. I know this sounds like a poor solution, but would you try importing astroplan in an hour, or tomorrow?

@cristobal-sifon
Copy link
Author

I see, I'll try tomorrow again and let you know then. Thanks!

@bmorris3
Copy link
Contributor

bmorris3 commented Aug 3, 2018

@cristobal-sifon Should be working now!

@cristobal-sifon
Copy link
Author

nope, still get the same error. Updated astropy in the meantime, using 3.0.4 now

@wtgee
Copy link
Contributor

wtgee commented Oct 22, 2018

@cristobal-sifon not sure if you ever figured this out but I just ran into the same problem. Turns out it was osme mismatch between the cached version and the updated astropy trying to read it. For me clearing out the cache fixed the problem:

In [1]: from astropy.utils.data import clear_download_cache
In [2]: clear_download_cache()
In [3]: import astroplan

@jamessynge
Copy link

I'm encountering a potentially related problem. A build of POCS is attempting to execute astroplan.download_IERS_A(), and it appears that it successfully downloads the file, but then there is an error reported regarding the loaded file, perhaps indicating that it is corrupted.

$ python pocs/utils/data.py --folder $PANDIR/astrometry/data
Downloading http://maia.usno.navy.mil/ser7/finals2000A.all
|==========================================| 3.2M/3.2M (100.00%)         1s
Failed to download IERS A bulletin: invalid literal for int() with base 10: 'N'

@bsipocz
Copy link
Member

bsipocz commented Oct 26, 2018

@jamessynge - That's is a know bug in numpy 1.15.3, if you could downgrade to 1.15.2 it should go away (and will be fixed in 1.15.4)

@jamessynge
Copy link

jamessynge commented Oct 26, 2018

@bsipocz - thanks for the tip. Do you have a link to the bug by any chance?

@bsipocz
Copy link
Member

bsipocz commented Oct 27, 2018

numpy/numpy#12248 - it has been fixed and will be released in 1.15.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants