简体   繁体   English

Librosa 在 Docker 中引发 OSError('sndfile library not found')

[英]Librosa raised OSError('sndfile library not found') in Docker

I'm trying to write the Dockerfile for a small python web project and there is something wrong with the dependencies.我正在尝试为小型 python web 项目编写 Dockerfile 项目,并且依赖项有问题。 I've been doing some search on the internet and it said that Librosa library requires libsndfile to work properly so I tried to install it using apt-get install libsndfile1 (I've also tried libsndfile-dev,...).我一直在互联网上进行一些搜索,它说 Librosa 库需要 libsndfile 才能正常工作,所以我尝试使用apt-get install libsndfile1安装它(我也尝试过 libsndfile-dev,...)。 However, it doesn't seem to solve my problem.但是,它似乎并没有解决我的问题。

This is how my Dockerfile looks like:这就是我的 Dockerfile 的样子:

FROM python:3.6-buster as build

ENV STATIC_URL /static
ENV STATIC_PATH /var/www/app/static

WORKDIR /var/www/

RUN python -m venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"

COPY requirements.txt .

RUN pip install -r requirements.txt

RUN pip install gunicorn

RUN apt-get update -y && apt-get install -y --no-install-recommends build-essential gcc \
                                        libsndfile1 

FROM python:3.6-buster AS run

COPY --from=build /opt/venv /opt/venv

COPY . .

ENV PATH="/opt/venv/bin:$PATH"

RUN gunicorn -b :5000 --access-logfile - --error-logfile - app:app

However, when i try to build and run this, this error occured:但是,当我尝试构建并运行它时,发生了这个错误:

[2020-04-15 17:30:02 +0000] [7] [INFO] Starting gunicorn 20.0.4
[2020-04-15 17:30:02 +0000] [7] [INFO] Listening at: http://0.0.0.0:5000 (7)
[2020-04-15 17:30:02 +0000] [7] [INFO] Using worker: sync
[2020-04-15 17:30:02 +0000] [10] [INFO] Booting worker with pid: 10
[2020-04-15 17:30:03 +0000] [10] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/opt/venv/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/opt/venv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
    self.load_wsgi()
  File "/opt/venv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/opt/venv/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/opt/venv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
    return self.load_wsgiapp()
  File "/opt/venv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/opt/venv/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
    mod = importlib.import_module(module)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app.py", line 12, in <module>
    from emotion_model.test import load_model, inference_segment
  File "/emotion_model/test.py", line 9, in <module>
    import librosa
  File "/opt/venv/lib/python3.6/site-packages/librosa/__init__.py", line 12, in <module>
    from . import core
  File "/opt/venv/lib/python3.6/site-packages/librosa/core/__init__.py", line 126, in <module>
    from .audio import *  # pylint: disable=wildcard-import
  File "/opt/venv/lib/python3.6/site-packages/librosa/core/audio.py", line 10, in <module>
    import soundfile as sf
  File "/opt/venv/lib/python3.6/site-packages/soundfile.py", line 142, in <module>
    raise OSError('sndfile library not found')
OSError: sndfile library not found
[2020-04-15 17:30:03 +0000] [10] [INFO] Worker exiting (pid: 10)
[2020-04-15 17:30:03 +0000] [7] [INFO] Shutting down: Master
[2020-04-15 17:30:03 +0000] [7] [INFO] Reason: Worker failed to boot.

For those who come to this post to find a solution.对于那些来这篇文章寻找解决方案的人。 My workaround was to put the installation of libsndfile after this part:我的解决方法是将 libsndfile 的安装放在这部分之后:

FROM python:3.6-buster AS run

COPY --from=build /opt/venv /opt/venv

COPY . .

ENV PATH="/opt/venv/bin:$PATH"

which would be:这将是:

FROM python:3.6-buster AS run

COPY --from=build /opt/venv /opt/venv

COPY . .

ENV PATH="/opt/venv/bin:$PATH"

RUN apt-get update -y && apt-get install -y --no-install-recommends build-essential gcc \
                                        libsndfile1 

RUN gunicorn -b :5000 --access-logfile - --error-logfile - app:app

I had a similar issue ran something like:我遇到了类似的问题,例如:

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
&& apt-get -y install apt-utils gcc libpq-dev libsndfile-dev \
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 azure 应用程序服务中部署时,librosa 中出现 OSError(&#39;sndfile library not found&#39;) - OSError('sndfile library not found') in librosa while deploying in azure app service Flask Heroku 部署的 Librosa 安装:“OSError: sndfile library not found”(H10 错误) - Librosa Installation for Flask Heroku Deployment: “OSError: sndfile library not found” (H10 error) 无法在 SageMaker Jupyter 笔记本实例“OSError:找不到 sndfile 库”上导入 librosa - Cannot import librosa on SageMaker Jupyter notebook instance "OSError: sndfile library not found" 为 TensorFlow 导入 librosa 时出错:找不到 sndfile 库 - Error importing librosa for TensorFlow: sndfile library not found 问题导入 python 声音文件库 - OSError: library not found: &#39;sndfile&#39; - Issue importing python soundfile library - OSError: library not found: 'sndfile' 在 Z1A79417461C9ADBE88F8B93E7FAD39 上部署音频预测 model 时出现“OSError: sndfile library not found”和“Unable to locate package libsndfile1”错误 - I am getting “OSError: sndfile library not found” & “Unable to locate package libsndfile1” errors when deploying audio prediction model on Heroku Python 在新安装的 Mac 上找不到 sndfile 库 - Python sndfile library not found on newly installed Mac 如何解决 Alpine docker 容器内 Flask 应用程序的 Gunicorn exec 上引发的“OSError:找不到 libc” - How to address 'OSError: libc not found' raised on Gunicorn exec of Flask app inside Alpine docker container Python 链接到错误的库文件夹 - 未找到 sndfile 库 - Python linking to wrong library folder - sndfile library not found OSError:找不到 PortAudio 库 - OSError: PortAudio library not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM