3

我试图在 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
>>> 

谁能帮我找出问题所在?

4

2 回答 2

1

也许“atpy”包依赖于您缺少的另一个名为“astropy.io”的包?是的,这里是https://astropy.readthedocs.org/en/v0.1/index.html

碰巧从 pypi.python.org 下载 tar 包是安装 Python 包的错误方法。正确的方法(尽管 Python 文档解释得不好)是运行类似的命令

pip install atpy

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

如果缺少该命令pip,则必须安装它,具有讽刺意味的是,这确实很复杂。

于 2013-04-04T10:28:25.720 回答
1

就我而言,解决方案是安装astropy

pip install --no-deps astropy

于 2014-07-13T07:09:35.980 回答