Linux寫配置HDF5的python包h5py


        閑言碎語不講,直接進入正題。Python在科學計算的應用越來越豐度,而hdf(5)數據的應用也非常廣泛。python提供了h5py包供開發者處理數據(http://www.h5py.org/)。在windows下配置h5py,可以通過安裝Anaconda以及pythonxy來做相對方便,現在主要說在linux下該環境的配置。

(1)使用: sudo apt-get install python-pip安裝pip工具,然后使用pip install numpy和pip install numpy安裝基本環境。

(2)使用: sudo apt-get install libhdf5-dev安裝hdf的開發庫(重要)。否則會報出:

#include “hdf5.h”

compilation terminated.

error: command ‘gcc’ failed with exit status:1

(3)安裝HDF5:按照官方文檔的說明就可以(ftp://ftp.hdfgroup.org/HDF5/current/src/unpacked/release_docs/INSTALL)。

$tar zxf hdf5-X.Y.Z.tar.gz$ cd hdf5-X.Y.Z
$ ./configure --prefix=/your/install/dir <more configure_flags>
$ sudo make
$ sudo make check                # run test suite.
$ sudo make install
$ sudo make check-install        # verify installation.

這里也有一個安裝教程,是我后來發現的:(http://www.aichengxu.com/view/24309)

(4)使用:sudo pip install h5py安裝h5py庫,當你看到Successfully install h5py. Cleaning up…就大功告成了。

(5)測試一下:

import h5py as h5

h5.run_tests()

成功運行。

 

具體使用可以參照幫助文檔(http://docs.h5py.org/en/latest/build.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM