Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to run a Python script that uses the module netCDF4. Therefore I followed the instructions here: http://netcdf4-python.googlecode.com/svn/trunk/docs/netCDF4-module.html

For what reason ever, it doesn't work with the HDF5-Version I installed. I installed the latest version (1.8.10) in my home-directory. But Python comes with this error:

$ import netCDF4
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/user/timo/<ipython-input-2-f731da2de255> in <module>()
----> 1 import netCDF4
/user/timo/netCDF4.pyx in init netCDF4 (netCDF4.c:46771)()
ImportError: netCDF4 module must be linked against HDF5 version 1.8.4-patch1 or higher, got 1.8.10

So I deleted the folders for the 1.8.10-Version (manually) from my home dir and installed the 1.8.4-patch1. (Maybe the '.10'-version is not compatible?)

But this doesn't solve the problem. The error when I run the Python script is still the same. That's why I thought there must be somewhere anything of the '.10'-version I did not delete, so I searched for 'hdf5':

4> sudo find / -name 'hdf5'
/user/timo/hdf5
/user/timo/Downloads/hdf5-1.8.4-patch1/windows/proj/hdf5

(in '/user/timo/hdf5' is the installed '1.8.4-patch1'-version)

I guess my Python script will run, after I have deleted the '1.8.10'-version completely. Can anyone help me out?

(I'm using 'Ubuntu 12.04.1 LTS' and 'Python2.7')

share|improve this question

2 Answers 2

I am definitely also not an expert but looking at the netCDF4 page you have linked, you'll probably have to rebuild it after installing the older HDF5 version.

However I am wondering if you build netCDF4 with the flags that are listed under "Required", why the newest version should not work.

What does export say? Are your HDF5 variables set correct?

share|improve this answer

I would remove both netCDF4 and HDF5 by running

apt-get remove --purge python-netcdf hdf5

This will also make go away related packages.

This might be more safe:

dpkg -r python-netcdf hdf5
apt-get autoremove

followed by reinstallation of netCDF4 and dependencies, used most from an article for Ubuntu 14 LTS.

apt-get install git git-doc git-el git-email git-gui gitk gitweb git-arch git-bzr git-cvs git-mediawiki git-svn python python-dev python-pip libatlas-base-dev gcc gfortran g++ cython

this is good for avoiding later scipy python module errors [from www.scipy.org ]

apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

(re)install zlib library:

ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/zlib-1.2.8.tar.gz
cd /home/user/Downloads
tar xvzf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure 
make 
make install

(re)install curl:

apt-get install curl

(re)install HDF5:

ftp.unidata.ucar.edu/pub/netcdf/netcdf-4/hdf5-1.8.9.tar.gz
cd /home/user/Downloads 
tar xvzf hdf5-1.8.9.tar.gz
cd hdf5-1.8.9
./configure --prefix=/usr/local --enable-shared --enable-hl
make -j 2
make install

(re)install netCDF4:

ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.2.tar.gz
cd /home/user/Downloads
tar xvzf netcdf-4.3.2.tar.gz
cd netcdf-4.3.2

LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include ./configure --enable-netcdf-4 --enable-dap --enable-shared --prefix=/usr/local
make -j 2
make install
make check

and at last the netCDF4 module

pip install netcdf4

now the python "import netCDF4" should work

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.