Skip to content

Installation with pip: sndfile.h: No such file or directory #396

@michaelklachko

Description

@michaelklachko

Not sure if this is the right place to ask for help, but while trying to run this code, I'm failing with an error that's pointing to your library:


$ python preprocess_LibriSpeech.py
Traceback (most recent call last):
  File "preprocess_LibriSpeech.py", line 17, in <module>
    import soundfile as sf
  File "/home/michael/miniconda2/envs/SpeechRecog/lib/python3.5/site-packages/soundfile.py", line 267, in <module>
    _snd = _ffi.dlopen('sndfile')
  File "/home/michael/miniconda2/envs/SpeechRecog/lib/python3.5/site-packages/cffi/api.py", line 141, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/home/michael/miniconda2/envs/SpeechRecog/lib/python3.5/site-packages/cffi/api.py", line 802, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/home/michael/miniconda2/envs/SpeechRecog/lib/python3.5/site-packages/cffi/api.py", line 797, in _load_backend_lib
    raise OSError(msg)
OSError: ctypes.util.find_library() did not manage to locate a library called 'sndfile'

When I tried to install sndfile library with pip, I'm getting the following error:

$ pip install sndfile
Collecting sndfile
  Using cached https://files.pythonhosted.org/packages/f2/74/d7bb58d9aa8b808cf035814a0caad5245da72399a4078725a4dfc561762c/sndfile-0.1.2.tar.gz
Requirement already satisfied: cffi>=1.0.0 in /home/michael/miniconda2/envs/SpeechRecog/lib/python3.5/site-packages (from sndfile) (1.11.5)
Requirement already satisfied: pycparser in /home/michael/miniconda2/envs/SpeechRecog/lib/python3.5/site-packages (from cffi>=1.0.0->sndfile) (2.18)
Building wheels for collected packages: sndfile
  Running setup.py bdist_wheel for sndfile ... error
  Complete output from command /home/michael/miniconda2/envs/SpeechRecog/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-e52aippu/sndfile/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-p0bs1h3c --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/sndfile
  copying sndfile/__init__.py -> build/lib.linux-x86_64-3.5/sndfile
  copying sndfile/build.py -> build/lib.linux-x86_64-3.5/sndfile
  copying sndfile/formats.py -> build/lib.linux-x86_64-3.5/sndfile
  copying sndfile/io.py -> build/lib.linux-x86_64-3.5/sndfile
  running build_ext
  generating cffi module 'build/temp.linux-x86_64-3.5/sndfile._sndfile.c'
  creating build/temp.linux-x86_64-3.5
  building 'sndfile._sndfile' extension
  creating build/temp.linux-x86_64-3.5/build
  creating build/temp.linux-x86_64-3.5/build/temp.linux-x86_64-3.5
  gcc -pthread -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/michael/miniconda2/envs/SpeechRecog/include/python3.5m -c build/temp.linux-x86_64-3.5/sndfile._sndfile.c -o build/temp.linux-x86_64-3.5/build/temp.linux-x86_64-3.5/sndfile._sndfile.o
  build/temp.linux-x86_64-3.5/sndfile._sndfile.c:494:21: fatal error: sndfile.h: No such file or directory
  compilation terminated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for sndfile
  Running setup.py clean for sndfile
Failed to build sndfile
Installing collected packages: sndfile
  Running setup.py install for sndfile ... error
    Complete output from command /home/michael/miniconda2/envs/SpeechRecog/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-e52aippu/sndfile/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-gsl8uwor/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.5
    creating build/lib.linux-x86_64-3.5/sndfile
    copying sndfile/__init__.py -> build/lib.linux-x86_64-3.5/sndfile
    copying sndfile/build.py -> build/lib.linux-x86_64-3.5/sndfile
    copying sndfile/formats.py -> build/lib.linux-x86_64-3.5/sndfile
    copying sndfile/io.py -> build/lib.linux-x86_64-3.5/sndfile
    running build_ext
    generating cffi module 'build/temp.linux-x86_64-3.5/sndfile._sndfile.c'
    creating build/temp.linux-x86_64-3.5
    building 'sndfile._sndfile' extension
    creating build/temp.linux-x86_64-3.5/build
    creating build/temp.linux-x86_64-3.5/build/temp.linux-x86_64-3.5
    gcc -pthread -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/michael/miniconda2/envs/SpeechRecog/include/python3.5m -c build/temp.linux-x86_64-3.5/sndfile._sndfile.c -o build/temp.linux-x86_64-3.5/build/temp.linux-x86_64-3.5/sndfile._sndfile.o
    build/temp.linux-x86_64-3.5/sndfile._sndfile.c:494:21: fatal error: sndfile.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/home/michael/miniconda2/envs/SpeechRecog/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-e52aippu/sndfile/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-gsl8uwor/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-e52aippu/sndfile/

Any help is appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions