pytorch / audio

Data manipulation and transformation for audio signal processing, powered by PyTorch
https://pytorch.org/audio
BSD 2-Clause "Simplified" License
2.43k stars 636 forks source link

torchaudio/lib/libtorchaudio_sox.so, 0x0006): Library not loaded: @rpath/libsox.dylib #3724

Open luohao123 opened 5 months ago

luohao123 commented 5 months ago

torchaudio/lib/libtorchaudio_sox.so, 0x0006): Library not loaded: @rpath/libsox.dylib

installed pip install sox not work

ashwin-jain commented 4 months ago

same problem for me. macos. already done pip install sox and brew install sox

spudMelf commented 2 months ago

I had the same issue. It seems the way sox is used in pytorch has changed for versions >= 2.0 https://pytorch.org/audio/2.1.0/torchaudio.html#i-o.

This worked for me:

  1. Make sure you have sox installed
    brew install sox
  2. Set environment variable for torchaudio
    export BUILD_SOX=1
  3. Uninstall current torch version and rollback to a 1.X version https://pytorch.org/get-started/previous-versions/. I used version 1.11.0 and it worked.

I think there's a way to still get it working with versions >=2.0 but not one I figured out. I think more info on related issues can be found here: https://github.com/pytorch/audio/issues/2950.

mrsndmn commented 1 month ago

Linking brew's libsox.dylib to python virtual environment solved this issue for me

ln -s $HOME/homebrew/lib/libsox.dylib $HOME/miniconda3/envs/ENVIRONMENT_NAME/lib/libsox.dylib