ATpy ImportError:没有名为astropy.io的模块

时间:2013-04-03 21:29:25

标签: python module osx-snow-leopard

我试图在python 2.7上获取atpy。我从

下载了ATpy0.9.6

https://pypi.python.org/pypi/ATpy/0.9.6

然后tar,然后运行:

cd ATpy0.9.6 sudo python setup.py install

事情似乎运作良好。

但是当我尝试在python上导入atpy时,我总是收到此错误消息:

ImportError:没有名为astropy.io的模块

更准确地说,

>>> import atpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/__init__.py", line 1, in <module>
    from .basetable import Table, TableSet, VectorException
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/basetable.py", line 15, in <module>
    from . import registry
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/registry.py", line 164, in <module>
    from . import fitstable
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/fitstable.py", line 8, in <module>
    from astropy.io import fits
ImportError: No module named astropy.io
>>> 

有人能帮我解决问题吗?

2 个答案:

答案 0 :(得分:1)

也许'atpy'包依赖于另一个名为'astropy.io'的包你不知道?是的,这是https://astropy.readthedocs.org/en/v0.1/index.html

从pypi.python.org下载tar球是安装Python包的错误方法。正确的方法(尽管Python文档解释得很差)是运行像

这样的命令
pip install atpy

此命令将安装您的软件包及其所有依赖项。

如果缺少命令pip,则必须安装它,具有讽刺意义的确非常复杂。

答案 1 :(得分:1)

在我的情况下,解决方案是安装astropy

pip install --no-deps astropy