2

I changed my username by following this thread: How do I change my username?

This was a few weeks ago and I have just encountered my first problem, Astropy (for python 2.7) is having trouble downloading files because it is looking in the wrong cache folder. Error message: IOError: [Errno 2] No such file or directory: u'/home/jill/.astropy/cache/download/py2/bf6211066f3d9a9b058d46183baba6ab' . (my old username was jill, and I can see that this file exists in my new home folder).

After debugging line by line, it seems as if the error is coming from the 'Shelve' module. As in, that is where /home/jill is first introduced in the url.

I have tried reinstalling python (sudo apt-get install --reinstall python2.7) and reinstalling astropy (pip2 uninstall astropy, pip2 install astropy).

*Full error message on Pycharm:

File "/home/jpsotka/Dropbox/Colibri/Simulation/corrections.py", line 74, in get_zenith
    elginfield_altaz = ecliptic(lat=elat*u.degree, lon=elon*u.degree).transform_to(AltAz(obstime=time, location=elginfield))

 File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/coordinates/baseframe.py", line 934, in transform_to
    return trans(self, new_frame)

File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/coordinates/transformations.py", line 1314, in __call__
    curr_coord = t(curr_coord, curr_toframe)

 File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/coordinates/transformations.py", line 914, in __call__
    return supcall(fromcoord, toframe)

 File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/coordinates/builtin_frames/cirs_observed_transforms.py", line 53, in cirs_to_altaz
    xp, yp = get_polar_motion(obstime)

 File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/coordinates/builtin_frames/utils.py", line 43, in get_polar_motion
    xp, yp, status = iers.IERS_Auto.open().pm_xy(time, return_status=True)

 File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/utils/iers/iers.py", line 600, in open
    cls.iers_table = cls.read(file=filename)

 File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/utils/iers/iers.py", line 456, in read
    iers_a = Table.read(file, format='cds', readme=readme)

  File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/table/table.py", line 2521, in read
    out = io_registry.read(cls, *args, **kwargs)

 File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/io/registry.py", line 531, in read
    data = reader(*args, **kwargs)

 File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/io/ascii/connect.py", line 39, in io_read
    return read(filename, format=format, **kwargs)

File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/io/ascii/ui.py", line 353, in read
    dat = reader.read(table)

File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/io/ascii/cds.py", line 322, in read
    return super(Cds, self).read(table)

File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/io/ascii/core.py", line 1159, in read
    self.lines = self.inputter.get_lines(table)

File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/io/ascii/core.py", line 296, in get_lines
    encoding=self.encoding) as fileobj:

File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()

  File "/home/jpsotka/.local/lib/python2.7/site-packages/astropy/utils/data.py", line 206, in get_readable_fileobj
    fileobj = open(name_or_obj, 'rb')

IOError: [Errno 2] No such file or directory: u'/home/jill/.astropy/cache/download/py2/bf6211066f3d9a9b058d46183baba6ab'

Process finished with exit code 1
1

If you are using astropy 1.0.10 or later, this should clear the cache without issue:

#! /usr/bin/env python
from astropy.utils import data
data.clear_download_cache()

Link to documentation:

astropy.utils.data.clear_download_cache(hashorurl=None)

[source]

Clears the data file cache by deleting the local file(s).

Parameters: hashorurl : str or None

If None, the whole cache is cleared. Otherwise, either specifies a hash for the cached file that is supposed to be deleted, or a URL that should be removed from the cache if present.

https://docs.astropy.org/en/stable/api/astropy.utils.data.clear_download_cache.html

Link to related bug and pull request:

https://github.com/astropy/astropy/issues/4427

https://github.com/astropy/astropy/pull/4810

1

I know of no way to completely avoid this, i.e. to make Python skip the nonexistant cache. However, there is one simple way to get your programs working again, and that is to make it appear that there is a cache (or whatever resource) in the /home/jill folder. You do this by creating a symbolic link called /home/jill to the (real) /home/jpsotka:

sudo ln -s /home/jpsotka /home/jill

That's all. Of course, if there is another user jill on the system, the directory /home/jill will already exist, and so the link can't be created.

I suppose that after a while, the files in the cache will be completely replaced, and you can remove the link:

sudo rm /home/jill 

Notice that this does not remove the folder that the link points to, just the link itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.