[英]I am getting “OSError: sndfile library not found” & “Unable to locate package libsndfile1” errors when deploying audio prediction model on Heroku
The objective is to deploy an audio prediction ML model on Heroku, which uses librosa library from python.目标是在 Heroku 上部署音频预测 ML model,它使用来自 python 的 librosa 库。
The app.py file uses librosa library to extract features from the audio. app.py 文件使用 librosa 库从音频中提取特征。
When I try to deploy on Heroku, I get an error as shown below.当我尝试在 Heroku 上部署时,出现如下所示的错误。
2020-06-12T03:27:43.099874+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/librosa/core/audio.py", line 10, in <module>
2020-06-12T03:27:43.099875+00:00 app[web.1]: import soundfile as sf
2020-06-12T03:27:43.099875+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/soundfile.py", line 142, in <module>
2020-06-12T03:27:43.099876+00:00 app[web.1]: raise OSError('sndfile library not found')
2020-06-12T03:27:43.099876+00:00 app[web.1]: OSError: sndfile library not found
2020-06-12T03:27:43.101008+00:00 app[web.1]: [2020-06-12 03:27:43 +0000] [11] [INFO] Worker exiting (pid: 11)
2020-06-12T03:27:43.255623+00:00 app[web.1]: [2020-06-12 03:27:43 +0000] [4] [INFO] Shutting down: Master
2020-06-12T03:27:43.255725+00:00 app[web.1]: [2020-06-12 03:27:43 +0000] [4] [INFO] Reason: Worker failed to boot.
2020-06-12T03:27:43.333827+00:00 heroku[web.1]: Process exited with status 3
2020-06-12T03:27:43.371190+00:00 heroku[web.1]: State changed from starting to crashed
Here is a snapshot of my buildpacks that I am using to install the dependencies: Build pack list这是我用来安装依赖项的构建包的快照:构建包列表
Below is the list of dependencies mentioned in requirements.txt:下面是 requirements.txt 中提到的依赖项列表:
Flask==1.1.1
gunicorn==19.9.0
itsdangerous==1.1.0
Jinja2==2.10.1
MarkupSafe==1.1.1
Werkzeug==0.15.5
numpy>=1.9.2
scipy>=0.15.1
scikit-learn>=0.18
matplotlib>=1.4.3
pandas>=0.19
librosa==0.7.2
aniso8601==8.0.0
audioread==2.1.5
I have also created an Aptfile to install libsndfile1.我还创建了一个 Aptfile 来安装 libsndfile1。 I have linked a build-pack on Heroku to install from this Aptfile.我已经在 Heroku 上链接了一个构建包,以便从此 Aptfile 安装。 Below is the list mentioned in my Aptfile:以下是我的 Aptfile 中提到的列表:
libsndfile1
libsndfile-dev
libasound2-dev
python-dev
python-numpy
python-setuptools
Here is the image of error "Unable to locate package libsndfile1" while deploying on Heroku这是在 Heroku 上部署时出现错误“无法找到 package libsndfile1”的图像
How to overcome the "OSError: sndfile library not found" and "Unable to locate package libsndfile1" errors?如何克服“OSError: sndfile library not found”和“Unable to locate package libsndfile1”错误?
I have uploaded all the files to GitHub here for more information.我已将所有文件上传到 GitHub此处以获取更多信息。
Update (12/14/2020) : I changed my Aptfile and requirements.txt contents, and it worked.更新(2020 年 12 月 14 日) :我更改了我的 Aptfile 和 requirements.txt 内容,它起作用了。
Here are the contents of Aptfile:以下是 Aptfile 的内容:
libsndfile1
libsndfile-dev
ffmpeg
Here are the contents of Aptfile:以下是 Aptfile 的内容:
aniso8601==8.0.0
audioread==2.1.8
certifi==2019.11.28
cffi==1.14.0
Click==7.0
decorator==4.4.2
ffmpeg-python==0.2.0
Flask==1.1.1
Flask-RESTful==0.3.8
future==0.18.2
gunicorn==20.0.4
itsdangerous==1.1.0
Jinja2==2.11.1
joblib==0.14.1
librosa==0.7.2
llvmlite==0.31.0
MarkupSafe==1.1.1
marshmallow==3.2.2
numba==0.48.0
numpy==1.18.1
pycparser==2.20
pydub==0.23.1
pytz==2019.3
resampy==0.2.2
scikit-learn==0.22.2.post1
scipy==1.4.1
six==1.14.0
SoundFile==0.10.3.post1
Werkzeug==1.0.0
wincertstore==0.2
pandas==1.0.1
pathlib==1.0.1
You need to install sndfile
as a package in your operating system.您需要在操作系统中将sndfile
安装为 package。 This answer documents how to do that on Heroku. 此答案记录了如何在 Heroku 上执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.