I am using Docker(Linux Container) on Windows 10 Pro machine.I created a docker container to run my flask application and have mentioned the required libraries in the requirements.txt file.
When i run docker container i got the below message
OSError: ctypes.util.find_library() did not manage to locate a library called 'sndfile'.
How do i install the sndfile library in Docker?
Referring to link :https://pysoundfile.readthedocs.io/en/0.9.0/ I have tried to install libsndfile with below command in Dockerfile
---- RUN apt-get install libsndfile1
Got Below message from docker build:
Step 5/7 : RUN apt-get install libsndfile1
---> Running in <container>
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libsndfile1
The command '/bin/sh -c apt-get install libsndfile1' returned a non-zero code: 100
1.DOCKER VERSION:
Client:
Version: 17.03.1-ce-rc1
API version: 1.27
Go version: go1.7.5
Git commit: 3476dbf
Built: Wed Mar 15 20:33:22 2017
OS/Arch: windows/amd64
Server:
Version: 17.03.1-ce-rc1
API version: 1.27 (minimum version 1.12)
Go version: go1.7.5
Git commit: 3476dbf
Built: Wed Mar 15 20:28:18 2017
OS/Arch: linux/amd64
Experimental: true
2.requirements.txt file
flask
tensorflow-gpu
flask_cors
uuid
librosa
pysoundfile
numpy
cffi
requests
wave
h5py
pydub
werkzeug
Complete Error Message:
File "app.py", line 5, in <module>
import librosa
File "/usr/local/lib/python3.7/site-packages/librosa/__init__.py", line 13, in <module>
from . import core
File "/usr/local/lib/python3.7/site-packages/librosa/core/__init__.py", line 115, in <module>
from .audio import * # pylint: disable=wildcard-import
File "/usr/local/lib/python3.7/site-packages/librosa/core/audio.py", line 8, in <module>
import soundfile as sf
File "/usr/local/lib/python3.7/site-packages/soundfile.py", line 267, in <module>
_snd = _ffi.dlopen('sndfile')
File "/usr/local/lib/python3.7/site-packages/cffi/api.py", line 146, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "/usr/local/lib/python3.7/site-packages/cffi/api.py", line 828, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "/usr/local/lib/python3.7/site-packages/cffi/api.py", line 823, in _load_backend_lib
raise OSError(msg)
OSError: ctypes.util.find_library() did not manage to locate a library called 'sndfile'
I did a quick test. It seems you are missing apt-get -y update
command.
Try to add RUN apt-get -y update
before that RUN apt-get install libsndfile1
line.
Here is what I tried and it worked.
$ cat Dockerfile
FROM ubuntu
RUN apt-get -y update
RUN apt-get install -y libsndfile1
CMD /bin/bash
$
$
$ docker build -t t:t .
Sending build context to Docker daemon 1.748MB
Step 1/4 : FROM ubuntu
---> 4c108a37151f
Step 2/4 : RUN apt-get -y update
---> Using cache
---> 55bfc92d838b
Step 3/4 : RUN apt-get install -y libsndfile1
---> Running in d5722e1f85f1
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libflac8 libogg0 libvorbis0a libvorbisenc2 multiarch-support
The following NEW packages will be installed:
libflac8 libogg0 libsndfile1 libvorbis0a libvorbisenc2 multiarch-support
0 upgraded, 6 newly installed, 0 to remove and 8 not upgraded.
Need to get 564 kB of archives.
After this operation, 2300 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 multiarch-support amd64 2.27-3ubuntu1 [6916 B]
Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 libogg0 amd64 1.3.2-1 [17.2 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic/main amd64 libflac8 amd64 1.3.2-1 [213 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic/main amd64 libvorbis0a amd64 1.3.5-4.2 [86.4 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic/main amd64 libvorbisenc2 amd64 1.3.5-4.2 [70.7 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libsndfile1 amd64 1.0.28-4ubuntu0.18.04.1 [170 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 564 kB in 1s (925 kB/s)
Selecting previously unselected package multiarch-support.
(Reading database ... 4040 files and directories currently installed.)
Preparing to unpack .../multiarch-support_2.27-3ubuntu1_amd64.deb ...
Unpacking multiarch-support (2.27-3ubuntu1) ...
Setting up multiarch-support (2.27-3ubuntu1) ...
Selecting previously unselected package libogg0:amd64.
(Reading database ... 4043 files and directories currently installed.)
Preparing to unpack .../libogg0_1.3.2-1_amd64.deb ...
Unpacking libogg0:amd64 (1.3.2-1) ...
Selecting previously unselected package libflac8:amd64.
Preparing to unpack .../libflac8_1.3.2-1_amd64.deb ...
Unpacking libflac8:amd64 (1.3.2-1) ...
Selecting previously unselected package libvorbis0a:amd64.
Preparing to unpack .../libvorbis0a_1.3.5-4.2_amd64.deb ...
Unpacking libvorbis0a:amd64 (1.3.5-4.2) ...
Selecting previously unselected package libvorbisenc2:amd64.
Preparing to unpack .../libvorbisenc2_1.3.5-4.2_amd64.deb ...
Unpacking libvorbisenc2:amd64 (1.3.5-4.2) ...
Selecting previously unselected package libsndfile1:amd64.
Preparing to unpack .../libsndfile1_1.0.28-4ubuntu0.18.04.1_amd64.deb ...
Unpacking libsndfile1:amd64 (1.0.28-4ubuntu0.18.04.1) ...
Setting up libogg0:amd64 (1.3.2-1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up libvorbis0a:amd64 (1.3.5-4.2) ...
Setting up libflac8:amd64 (1.3.2-1) ...
Setting up libvorbisenc2:amd64 (1.3.5-4.2) ...
Setting up libsndfile1:amd64 (1.0.28-4ubuntu0.18.04.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Removing intermediate container d5722e1f85f1
---> 983dbe47e769
Step 4/4 : CMD /bin/bash
---> Running in 286008c87197
Removing intermediate container 286008c87197
---> b302a2c7c958
Successfully built b302a2c7c958
Successfully tagged t:t
$
Also if possible try to put apt-get -y update && apt-get install -y libsndfile1
in single RUN command in Dockerfile. That is the best practice check this.
Hope this helps.