3

我正在尝试部署一个使用 TensorFlow 和 Librosa 的烧瓶应用程序。因此,作为 Librosa 的依赖项,我需要sndfile包。

当我运行我的 Flask 应用程序时,我收到此错误:

import librosa
  File "/home/ec2-user/.local/lib/

python3.7/site-packages/librosa/__init__.py", line 211, in <module>
    from . import core
  File "/home/ec2-user/.local/lib/python3.7/site-packages/librosa/core/__init__.py", line 6, in <module>
    from .audio import *  # pylint: disable=wildcard-import
  File "/home/ec2-user/.local/lib/python3.7/site-packages/librosa/core/audio.py", line 8, in <module>
    import soundfile as sf
  File "/home/ec2-user/.local/lib/python3.7/site-packages/soundfile.py", line 142, in <module>
    raise OSError('sndfile library not found')
OSError: sndfile library not found
[ec2-user@ip-172-31-90-51 CE_Ayush_Deployment]$ python3 app.py
Traceback (most recent call last):
  File "app.py", line 2, in <module>
    from model_pipeline import Corona_Diagnoser
  File "/home/ec2-user/CE_Ayush_Deployment/model_pipeline.py", line 5, in <module>
    import librosa
  File "/home/ec2-user/.local/lib/python3.7/site-packages/librosa/__init__.py", line 211, in <module>
    from . import core
  File "/home/ec2-user/.local/lib/python3.7/site-packages/librosa/core/__init__.py", line 6, in <module>
    from .audio import *  # pylint: disable=wildcard-import
  File "/home/ec2-user/.local/lib/python3.7/site-packages/librosa/core/audio.py", line 8, in <module>
    import soundfile as sf
  File "/home/ec2-user/.local/lib/python3.7/site-packages/soundfile.py", line 142, in <module>
    raise OSError('sndfile library not found')
OSError: sndfile library not found

我试过了:

sudo yum install autoconf autogen automake build-essential libasound2-dev \
   libflac-dev libogg-dev libtool libvorbis-dev libopus-dev libmp3lame-dev \
   libmpg123-dev pkg-config python

然后我收到这条消息:

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
No package build-essential available.
No package libasound2-dev available.
No package libflac-dev available.
No package libogg-dev available.
No package libvorbis-dev available.
No package libopus-dev available.
No package libmp3lame-dev available.
No package libmpg123-dev available.
No package pkg-config available.

我知道该软件包在 Amazon EC2 实例中不可用。谁能指导我如何将 sndfile 包安装到系统中?

4

2 回答 2

1

亚马逊 Linux 2

我在Amazon Linux 2上,您可以通过在 EC2 服务器上运行以下命令来验证。

[ec2-user@fake-ip ~]$ cat /etc/system-release
Amazon Linux release 2 (Karoo)

可以从Amazon 包存储库获得以下包:libsndfile-devellibsndfile-utilslibsndfile

 [ec2-user@fakeip ~]$ yum search libsndfile
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
=============================================== N/S matched: libsndfile ================================================
libsndfile-devel.x86_64 : Development files for libsndfile
libsndfile-utils.x86_64 : Command Line Utilities for libsndfile
libsndfile.x86_64 : Library for reading and writing sound files
libsndfile.i686 : Library for reading and writing sound files

亚马逊 Linux AMI

根据Amazon Linux AMI 软件包列表,此早期版本的 Amazon Linux 没有 libsndfile。尽管您可以启用 Extra Packages for Enterprise Linux (EPEL),但 libsndfile 似乎也不存在。

[ec2-user@fakeip ~]$ cat /etc/system-release
Amazon Linux AMI release 2018.03
[ec2-user@fakeip ~]$ sudo yum-config-manager --enable epel
... skipping lots of output
mirrorlist = https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=x86_64
...
[ec2-user@fakeip ~]$ yum search libsndfile
Loaded plugins: priorities, update-motd, upgrade-helper
epel/x86_64/metalink                         | 3.8 kB  00:00:00
epel                                         | 4.7 kB  00:00:00
(1/3): epel/x86_64/group_gz                  |  74 kB  00:00:00
(2/3): epel/x86_64/updateinfo                | 788 kB  00:00:00
(3/3): epel/x86_64/primary_db                | 6.1 MB  00:00:00
1067 packages excluded due to repository priority protections
Warning: No matches found for: libsndfile
No matches found

libsndfile文档声明它已在Debian/GNU Linux上编译,但 Amazon Linux AMI 不是基于 Debian。libsndfile ( autoconf autogen automake build-essential libasound2-dev libflac-dev libogg-dev libtool libvorbis-dev libopus-dev libmp3lame-dev libmpg123-dev pkg-config python) 的构建依赖项都引用了 Debian 软件包,这些软件包在其他 Linux 风格中没有相同的名称。特别是 , , build-essential,和不在EPEL 上。libasound2-devlibflac-devlibopus-devlibmp3lame-devlibmpg123-dev

[ec2-user@fakeip ~]$ yum search autoconf autogen automake build-essential \
    libasound2-dev   libflac-dev libogg-dev libtool libvorbis-dev libopus-dev \
    libmp3lame-dev   libmpg123-dev pkg-config python
... skipping output
Warning: No matches found for: build-essential
Warning: No matches found for: libasound2-dev
Warning: No matches found for: libflac-dev
Warning: No matches found for: libopus-dev
Warning: No matches found for: libmp3lame-dev
Warning: No matches found for: libmpg123-dev

libmpelame-dev可以是lame-devel, lame-libs,lame和/或lame-mp3x.

[ec2-user@fakeip ~]$ yum search lame
Loaded plugins: priorities, update-motd, upgrade-helper
1067 packages excluded due to repository priority protections
================================================== N/S matched: lame ===================================================
lame-devel.i686 : Development files for lame
lame-devel.x86_64 : Development files for lame
lame-libs.i686 : LAME MP3 encoding library
lame-libs.x86_64 : LAME MP3 encoding library
flamerobin.x86_64 : Graphical client for Firebird
lame.x86_64 : Free MP3 audio compressor
lame-mp3x.x86_64 : MP3 frame analyzer

libflac-dev或许flac-devel

[ec2-user@fakeip ~]$ yum search flac
Loaded plugins: priorities, update-motd, upgrade-helper
1067 packages excluded due to repository priority protections
================================================== N/S matched: flac ===================================================
flac-devel.x86_64 : Development libraries and header files from FLAC
easytag.x86_64 : Tag editor for mp3, ogg, flac and other music files
flac.i686 : An encoder/decoder for the Free Lossless Audio Codec
flac.x86_64 : An encoder/decoder for the Free Lossless Audio Codec
mp3fs.x86_64 : FUSE filesystem to transcode FLAC to MP3 on the fly

libopus-dev或许opus-devel

[ec2-user@fakeip ~]$ yum search opus
Loaded plugins: priorities, update-motd, upgrade-helper
1067 packages excluded due to repository priority protections
================================================== N/S matched: opus ===================================================
opus-devel.i686 : Development package for opus
opus-devel.x86_64 : Development package for opus
opus.i686 : An audio codec for use in low-delay speech and audio communication
opus.x86_64 : An audio codec for use in low-delay speech and audio communication

libmpg123-devhttps://www.mpg123.org/

建议

  • 将您的 EC2 切换到 Amazon Linux 2 或 Ubuntu
  • 在 EC2 上的 Docker 映像中运行您的应用程序
于 2021-09-28T12:25:30.637 回答
0

您需要安装 libsndfile 及其开发文件。不幸的是,它没有打包在存储库中,但是您可以通过直接下载 RPM 来安装它

wget http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic//libsndfile-1.0.31-alt1.x86_64.rpm
wget http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic//libsndfile-devel-1.0.28-alt1.x86_64.rpm

sudo yum localinstall libsndfile-devel-1.0.31-alt1.x86_64.rpm

您还可以从源代码安装libsndfile

另一种选择是切换到 Ubuntu,其中包含libsndfilelibsndfile-dev. 如果您希望专门部署 tensorflow,那么您应该从AWS Deep Learning AMI开始。这些 AMI 由 AWS 构建,并附带驱动程序和一系列已安装的框架。这些 AMis 具有 Ubuntu 风格的版本。

于 2021-09-28T01:22:53.447 回答