如何在Mac上使用python读取CDF文件?

时间:2019-06-07 13:25:12

标签: python macos-mojave

我已使用以下命令(MacOS Mojave)安装了spacepy:

pip install git+https://github.com/spacepy/spacepy.git

但是在尝试from spacepy import pycdf时,我一直收到此错误:

  

异常:无法加载CDF C库;已检查。导入前,尝试使用“ os.environ [“ CDF_LIB”] = library_directory“。

我尝试遵循the directions from their website,但是这些指示似乎有点过时了。

1 个答案:

答案 0 :(得分:0)

您可以执行以下操作:

import os
os.environ["CDF_LIB"] = "~/CDF/lib" # Give the path of the cdf library
# e.g. in this case the library is in your home directory.

在做之前:

from spacepy import pycdf

可以在this SpacePy网站上找到错误的来源。

cdf库可用here

基本上,您需要在导入模块之前设置CDF_LIB(如果pycdf找不到它)。您可以阅读文档here