[Python] torchaudio can't find FFmpeg

Discussão em 'Python' iniciado por Stack, Julho 10, 2025.

  1. Stack

    Stack Membro Participativo

    Windows, vscode, Python 3.11.4-64bit

    import torch
    import torchaudio

    print(torch.__version__)
    print(torchaudio.__version__)
    print(torchaudio._extension._FFMPEG_INITIALIZED)


    2.0.1+cu117
    2.0.2+cu117
    False


    and i try

    torchaudio._extension._init_ffmpeg()


    Traceback (most recent call last):
    File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchaudio\_extension\utils.py", line 85, in _init_ffmpeg
    _load_lib("libtorchaudio_ffmpeg")
    File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchaudio\_extension\utils.py", line 61, in _load_lib
    torch.ops.load_library(path)
    File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\_ops.py", line 643, in load_library
    ctypes.CDLL(path)
    File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\ctypes\__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    FileNotFoundError: Could not find module 'C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchaudio\lib\libtorchaudio_ffmpeg.pyd' (or one of its dependencies). Try using the full path with constructor syntax.

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
    File "c:\Users\USER\Desktop\MyChatBot\0.py", line 6, in <module>
    torchaudio._extension._init_ffmpeg()
    File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchaudio\_extension\utils.py", line 87, in _init_ffmpeg
    raise ImportError("FFmpeg libraries are not found. Please install FFmpeg.") from err
    ImportError: FFmpeg libraries are not found. Please install FFmpeg.


    my libtorchaudio_ffmpeg.pyd exists and it's path is correct, but ctypes can't seem to find it. how should i do?

    I have also downloaded ffmpeg.

    C:\Users\USER>ffmpeg
    ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
    built with gcc 10.2.1 (GCC) 20200726


    but still not working. how should i do?

    Continue reading...

Compartilhe esta Página