我通过以下线程更改了我的用户名:如何更改我的用户名?
这是几周前的事,我刚刚遇到了第一个问题,Astropy (for python 2.7) 在下载文件时遇到问题,因为它在错误的缓存文件夹中查找。错误消息:IOError: [Errno 2] No such file or directory: u'/home/jill/.astropy/cache/download/py2/bf6211066f3d9a9b058d46183baba6ab' 。(我的旧用户名是 jill,我可以看到这个文件存在于我的新主文件夹中)。
逐行调试后,似乎错误来自“搁置”模块。如,这是 /home/jill 首次在 url 中引入的地方。
我尝试重新安装 python(sudo apt-get install --reinstall python2.7)并重新安装 astropy(pip2 卸载 astropy,pip2 安装 astropy)。
* 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
我知道没有办法完全避免这种情况,即让 Python 跳过不存在的缓存。但是,有一种简单的方法可以让您的程序再次运行,那就是让它看起来
/home/jill
文件夹中有缓存(或任何资源)。您可以通过创建一个名为/home/jill
(real) 的符号链接来做到这一点/home/jpsotka
:就这样。当然,如果
jill
系统中有其他用户,则该目录/home/jill
已经存在,因此无法创建链接。估计过一会缓存里的文件会被完全替换掉,可以去掉链接:
请注意,这不会删除 链接指向的文件夹,只是删除链接本身。
如果您使用的是 astropy 1.0.10 或更高版本,这应该会毫无问题地清除缓存:
文档链接:
https://docs.astropy.org/en/stable/api/astropy.utils.data.clear_download_cache.html
链接到相关的错误和拉取请求:
https://github.com/astropy/astropy/issues/4427
https://github.com/astropy/astropy/pull/4810