Django/Docker 中没有这样的文件或目录:“ffmpeg”

问题描述 投票:0回答:1

我在 Docker 中运行 Django 代码。我运行的转录软件需要 ffmpeg 才能运行。然而,每当我尝试运行我的代码时,我都会收到错误

[Errno 2] No such file or directory: 'ffmpeg'

这是我的观点.py:

def initiate_transcription(request, session_id):
    ...
                with open(file_path, 'rb') as f:
                    path_string = f.name
                    transcript = transcribe_file(path_string,audio_language, output_file_type)

   ...

这是我的 Dockerfile:

# Pull base image
FROM python:3.11.4-slim-bullseye

# Set environment variables
ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV COLUMNS 80

#install Debian and other dependencies that are required to run python apps(eg. git, python-magic).
RUN apt-get update \
 && apt-get install -y --force-yes \
 nano python3-pip gettext chrpath libssl-dev libxft-dev \
 libfreetype6 libfreetype6-dev  libfontconfig1 libfontconfig1-dev\
  && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y git
RUN apt-get update && apt-get install -y libmagic-dev
RUN apt-get -y update && apt-get -y upgrade && apt-get install -y --no-install-recommends ffmpeg


# Set working directory for Docker image
WORKDIR /code/

RUN apt-get update \
    && apt-get -y install libpq-dev gcc

# Install dependencies
COPY requirements.txt .
RUN pip install -r requirements.txt

# Copy project
COPY . .

我在网上搜索了可能的解决方案,但未能找到与我的问题类似的内容

python django docker ffmpeg
1个回答
0
投票

在 Dockerfile 中尝试使用以下行:

pip3 install --no-cache-dir ffmpeg-python

您可能还需要:

apt-get install -y ffmpeg
© www.soinside.com 2019 - 2024. All rights reserved.