PyTables: pip tables install fails, HDF5 library not found

Hi PyTables team,

Thanks for an awesome package, and apologies in advance if I am overlooking something simple.

I’ve been trying install pytables via pip using pip install tables, however, it fails with an error Could not find a local HDF5 installation.:

Downloading/unpacking tables
  Running setup.py egg_info for package tables
    /tmp/H5closew4kVON.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
    main (int argc, char **argv) {
    ^~~~
    /tmp/H5closew4kVON.c:2:5: warning: implicit declaration of function 'H5close' is invalid in C99 [-Wimplicit-function-declaration]
        H5close();
        ^
    2 warnings generated.
    ld: library not found for -lhdf5
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    * Found numpy 1.7.0 package installed.
    * Found numexpr 2.0.1 package installed.
    * Found Cython 0.18 package installed.
    ld: library not found for -lhdf5
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    .. ERROR:: Could not find a local HDF5 installation.
       You may need to explicitly state where your local HDF5 headers and
       library can be found by setting the ``HDF5_DIR`` environment
       variable or by using the ``--hdf5`` command-line option.
    Complete output from command python setup.py egg_info:
    /tmp/H5closew4kVON.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]

main (int argc, char **argv) {

^~~~

/tmp/H5closew4kVON.c:2:5: warning: implicit declaration of function 'H5close' is invalid in C99 [-Wimplicit-function-declaration]

    H5close();

    ^

2 warnings generated.

ld: library not found for -lhdf5

clang: error: linker command failed with exit code 1 (use -v to see invocation)

* Found numpy 1.7.0 package installed.

* Found numexpr 2.0.1 package installed.

* Found Cython 0.18 package installed.

ld: library not found for -lhdf5

clang: error: linker command failed with exit code 1 (use -v to see invocation)

.. ERROR:: Could not find a local HDF5 installation.

   You may need to explicitly state where your local HDF5 headers and

   library can be found by setting the ``HDF5_DIR`` environment

   variable or by using the ``--hdf5`` command-line option.

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/tables
Storing complete log in /Users/nehalecky/.pip/pip.log

I do, however, have HDF5 installed via MacPorts, and can verify the installation with port contents hdf5-18:

Port hdf5-18 contains:
  /opt/local/bin/gif2h5
  /opt/local/bin/h52gif
  /opt/local/bin/h5c++
  /opt/local/bin/h5cc
  /opt/local/bin/h5copy
  /opt/local/bin/h5debug  
...
  /opt/local/include/H5ACpublic.h
  /opt/local/include/H5AbstractDs.h
  /opt/local/include/H5Apublic.h
  /opt/local/include/H5ArrayType.h
  /opt/local/include/H5AtomType.h
...
  /opt/local/lib/libhdf5.7.dylib
  /opt/local/lib/libhdf5.a
  /opt/local/lib/libhdf5.dylib
  /opt/local/lib/libhdf5.la
  /opt/local/lib/libhdf5.settings
...

I’ve set env var HDF5_DIR in .bash_profile with export HDF5_DIR=/opt/local, but still no love from the pytables installation. I’ve been searching the interwebs for a solution, and finally decided to ask the source. Any help with this would be much appreciated, and thank you for your time!

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 39 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Not sure if this helps anyone, but I got around this on OSX by installing hdf5 via homebrew with:

brew update
brew tap homebrew/science
brew install hdf5

then just pip install --upgrade tables

For anyone else who runs into this problem on Ubuntu (trusty in my case), I needed to apt-get install libhdf5-dev to get the header files, etc.

Hi I am facing the same error as @Shreeyak on a M1 Mac, macOS Monterey 12.4, Python 3.10.3

pip install tables

Collecting tables
  Using cached tables-3.7.0.tar.gz (8.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      /var/folders/6g/9c7g_2tx2sb7lp8ttwtfky640000gn/T/H5closexiq3dvaw.c:2:5: error: implicit declaration of function 'H5close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
          H5close();
          ^
      1 error generated.
      cpuinfo failed, assuming no CPU features: No module named 'cpuinfo'
      * Using Python 3.10.3 (v3.10.3:a342a49189, Mar 16 2022, 09:34:18) [Clang 13.0.0 (clang-1300.0.29.30)]
      * Found cython 0.29.30
      * USE_PKGCONFIG: False
      .. ERROR:: Could not find a local HDF5 installation.
         You may need to explicitly state where your local HDF5 headers and
         library can be found by setting the ``HDF5_DIR`` environment
         variable or by using the ``--hdf5`` command-line option.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

I tried to following the answer in this GitHub Issue:

pip install cython
brew install hdf5
brew install c-blosc
export HDF5_DIR=/usr/local/
export BLOSC_DIR=/usr/local/

Not sure if the paths are wrong given that Homebrew might handle brew install hdf5 on M1 Macs? I do have both hdf5 and c-blosc correctly installed though.

UPDATE:

Indeed, Homebrew puts the files into a different place on M1 Macs, the exports should be:

export HDF5_DIR=/opt/homebrew/opt/hdf5 
export BLOSC_DIR=/opt/homebrew/opt/c-blosc

I just faced this error. Ubuntu 18.04, python 3.8.

    ERROR: Command errored out with exit status 1:
     command: /home/shrek/anaconda3/envs/cloud/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0jegkgok/tables/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0jegkgok/tables/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-qhgorb0e
         cwd: /tmp/pip-install-0jegkgok/tables/
    Complete output (13 lines):
    /tmp/H5closeeqmynv_d.c: In function 'main':
    /tmp/H5closeeqmynv_d.c:2:5: warning: implicit declaration of function 'H5close' [-Wimplicit-function-declaration]
         H5close();
         ^~~~~~~
    /usr/bin/ld: cannot find -lhdf5
    collect2: error: ld returned 1 exit status
    * Using Python 3.8.5 (default, Aug  5 2020, 08:36:46)
    * USE_PKGCONFIG: True
    * Found conda env: ``/home/shrek/anaconda3/envs/cloud``
    .. ERROR:: Could not find a local HDF5 installation.
       You may need to explicitly state where your local HDF5 headers and
       library can be found by setting the ``HDF5_DIR`` environment
       variable or by using the ``--hdf5`` command-line option.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I installed HDF5, but still got a similar error message. This time though, it detected the location of hdf5 install. Wonder why it still failed:

sudo apt-get install libhdf5-serial-dev
    /usr/bin/ld: cannot find -lhdf5
    collect2: error: ld returned 1 exit status
    * Using Python 3.8.5 (default, Aug  5 2020, 08:36:46)
    * USE_PKGCONFIG: True
    * Found conda env: ``/home/shrek/anaconda3/envs/cloud``
    * pkg-config header dirs for HDF5: /usr/include/hdf5/serial
    * pkg-config library dirs for HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial
    .. ERROR:: Could not find a local HDF5 installation.
       You may need to explicitly state where your local HDF5 headers and
       library can be found by setting the ``HDF5_DIR`` environment
       variable or by using the ``--hdf5`` command-line option.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Maybe I needed to clear cache when installing via pip? Exporting env var HDF5_DIR solved it though:

export HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/serial

aha, this worked. thank you! well, my hdf5 came with Anaconda distribution.