ubuntu14.04中astropy0.3子包的加载问题

2024-06-08 12:25:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经在Ubuntu-14.04上成功地安装了带有python-3.4的astropy-0.3,但是每当我搜索任何传统的astropy库,比如宇宙学、时间、单位时,它在这里都不起作用。。这个库是专门为windows或其他东西设计的吗?你知道吗

我正在空闲的python-2.7上使用Astropy库。你知道吗

这个问题有什么解决办法吗?你知道吗


Tags: ubuntuwindows时间单位传统空闲astropy解决办法
1条回答
网友
1楼 · 发布于 2024-06-08 12:25:58

在Ubuntu 14.04及更高版本中打开终端并键入:

sudo apt install python3-astropy

现在要检查它是否工作,请打开IDLE3并在IDLE3中运行以下命令:

import astropy
from astropy.cosmology import WMAP9 as cosmo
dir(astropy)

dir(astropy)的预期输出是:

['ConfigurationItem', 'UNICODE_OUTPUT', '__builtins__', '__cached__', '__doc__', '__file__', '__githash__', '__loader__', '__minimum_numpy_version__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_check_numpy', '_get_test_runner', '_init_log', '_initialize_astropy', '_teardown_log', 'config', 'constants', 'coordinates', 'cosmology', 'cython_version', 'extern', 'find_api_page', 'io', 'log', 'logger', 'logging', 'online_docs_root', 'table', 'test', 'time', 'units', 'utils', 'version', 'version_helpers', 'wcs']

上面的输出显示,您在问题中提到的astropy的内置函数:宇宙学、时间和单位都已成功导入。你知道吗

下面的Python代码1是一个简单的测试,用于检查astropy的宇宙学和单位内置函数是否正常工作。从IDLE3运行以下命令:

from astropy.cosmology import WMAP9 as cosmo
H0 = cosmo.H(0)
H0.value, H0.unit

预期输出为:

(69.32, Unit("km / (Mpc s)"))

1来源:Cosmological Calculations (astropy.cosmology)

相关问题 更多 >