首先 安裝spacepy
pip install spacepy
然後會出現報錯
Exception: Cannot load CDF C library; checked . Try 'os.environ["CDF_LIB"] = library_directory' before import.
找到如下的解決方案
https://www.manongdao.com/article-348190.html
具體代碼如下:
wget -r -l1 -np -nd -nc http://cdaweb.gsfc.nasa.gov/pub/software/cdf/dist/latest-release/linux/ -A cdf*-dist-all.tar.gz
tar xf cdf*-dist-all.tar.gz -C ./
cd cdf*dist
pip install numpy scipy h5py matplotlib networkx
apt install build-essential gfortran libncurses5-dev
make all.help
make OS=linux ENV=gnu CURSES=yes FORTRAN=no UCOPTIONS=-O2 SHARED=yes -j4 all
make install #no sudo
#注意這裏需要改一下路徑;添加一下bashrc即可
. $HOME/Libraries/cdf/cdf36_3-dist/bin/definitions.B
# 進definitions.B改一下lin68,替換一下
export LD_LIBRARY_PATH=$HOME/Libraries/cdf/cdf36_3-dist/lib:$LD_LIBRARY_PATH
以上是可以解決如上報錯,但是在pycharm中依舊會報錯
理由是添加的bashrc無法在pycharm中識別。
這個時候就需要手動在pycharm的編譯器中添加相應的bash路徑了
添加路徑位置如圖所示