简体   繁体   中英

Cannot pip install the python module tables

I am trying to install tables so an existing python script does not complain when it tries to 'import tables'

pip install tables

Here is the output:

Collecting tables
  Using cached tables-3.2.3.1.tar.gz
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.8.0 in ./miniconda/envs/optimus/lib/python2.7/site-packages (from tables)
Requirement already satisfied (use --upgrade to upgrade): numexpr>=2.5.2 in ./miniconda/envs/optimus/lib/python2.7/site-packages (from tables)
Installing collected packages: tables
  Running setup.py install for tables: started
    Running setup.py install for tables: finished with status 'error'
    Complete output from command /home/jonathonhill/miniconda/envs/optimus/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-jcuNfM/tables/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ofzTc6-record/install-record.txt --single-version-externally-managed --compile:
    * Using Python 2.7.8 |Continuum Analytics, Inc.| (default, Aug 21 2014, 18:22:21)
    * USE_PKGCONFIG: True
    * pkg-config header dirs for HDF5: /usr/include/hdf5/serial
    * pkg-config library dirs for HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial
    * Found HDF5 headers at ``/usr/include/hdf5/serial``, library at ``/usr/lib/x86_64-linux-gnu/hdf5/serial``.
    .. WARNING:: Could not find the HDF5 runtime.
       The HDF5 shared library was *not* found in the default library
       paths. In case of runtime problems, please remember to install it.
    /tmp/lzo_version_dateanObdP.c:1:1: warning: return type defaults to âintâ [-Wimplicit-int]
     main (int argc, char **argv) {
     ^
    /tmp/lzo_version_dateanObdP.c: In function âmainâ:
    /tmp/lzo_version_dateanObdP.c:2:5: warning: implicit declaration of function âlzo_version_dateâ [-Wimplicit-function-declaration]
         lzo_version_date();
         ^
    * Could not find LZO 2 headers and library; disabling support for it.
    /tmp/lzo_version_datedINlTK.c:1:1: warning: return type defaults to âintâ [-Wimplicit-int]
     main (int argc, char **argv) {
     ^
    /tmp/lzo_version_datedINlTK.c: In function âmainâ:
    /tmp/lzo_version_datedINlTK.c:2:5: warning: implicit declaration of function âlzo_version_dateâ [-Wimplicit-function-declaration]
         lzo_version_date();
         ^
    * Could not find LZO 1 headers and library; disabling support for it.
    /tmp/BZ2_bzlibVersionL7B4pC.c:1:1: warning: return type defaults to âintâ [-Wimplicit-int]
     main (int argc, char **argv) {
     ^
    /tmp/BZ2_bzlibVersionL7B4pC.c: In function âmainâ:
    /tmp/BZ2_bzlibVersionL7B4pC.c:2:5: warning: implicit declaration of function âBZ2_bzlibVersionâ [-Wimplicit-function-declaration]
         BZ2_bzlibVersion();
         ^
    * Found bzip2 headers at ``/usr/include``, the library is located in the standard system search dirs.
    /tmp/blosc_list_compressorsQc0Mok.c:1:1: warning: return type defaults to âintâ [-Wimplicit-int]
     main (int argc, char **argv) {
     ^
    /tmp/blosc_list_compressorsQc0Mok.c: In function âmainâ:
    /tmp/blosc_list_compressorsQc0Mok.c:2:5: warning: implicit declaration of function âblosc_list_compressorsâ [-Wimplicit-function-declaration]
         blosc_list_compressors();
         ^
    * Could not find blosc headers and library; using internal sources.

I gather from this that I am missing a HDF5 shared library. How can I fix this error / install any necessary dependencies.

Your log explicitly tell what's wrong:

WARNING:: Could not find the HDF5 runtime.

Try this:

sudo python setup.py build_ext --inplace --hdf5=/opt/local --lzo=/opt/local --bzip2==opt/local

sudo python setup.py install --hdf5=/opt/local --lzo=/opt/local --bzip2==opt/local

Take a look at the project site page . You can download manually the dependeces ( blosc ), maybe the issue is given by a network problem, or can not be satisfy automatically.If you already have the library try to specify during the installation in this way:

python setup.py --blosc=/stuff/blosc-1.8.1

As you can read in the error message in the installation process:

  • HDF5 wasn't found: WARNING:: Could not find the HDF5 runtime.

  • LZO (neither 2 nor 1) wasn't found: * Could not find LZO 2 headers and library; disabling support for it. * Could not find LZO 2 headers and library; disabling support for it. * Could not find LZO 1 headers and library; disabling support for it.

  • Blosc wasn't found but it seems it can use the internal sources packed in with PyTables. * Could not find blosc headers and library; using internal sources. In my case, I also had to install it to make it work.

You have two options:

a) You can install the three libraries with apt and pip by doing:

sudo apt install python-blosc python-lzo
pip install h5py

b) Alternatively, if you're using Conda do:

conda install h5py python-blosc python-lzo 

If the python-lzo installation fails, try installing the base library:

sudo apt install liblzo2-dev

I tried all the provided solutions and none worked. I was using python 3.9.2 .

I ended up switching to python 3.8.0 and had no issues just running: pip install tables , which installed tables properly and everything worked as expected.

Just thought I'd add this as an answer for anyone who happens to be in the same situation as me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM