Please Help: `torchaudio` does not find the `sox` backend on macOS

Hello,

I’ve been struggling with torchaudio since I migrated to my new macBook Pro.

The problem is the following: torchaudio can not initialize the sox backend when

  • the Python environment is managed by uv,
  • and I debug from PyCharm or VSCode (the two IDEs I use for Python, I did not test any other),
  • even though sox is installed and the scripts run perfectly from the terminal (with the environment managed by uv).

The issue seems related to uv as I don’t have any problem if I manage the environment manually with venv and pip.
More details in my issue on uv repo.

However, the problems seems related to my environment somehow:

  • I did not encounter the issue on my previous computer (also a macBook Pro Apple Silicon).
  • If I work in a bash session with a much simpler environment (I have a quite complicated .zprofile file but no .bash_profile or .profile file), the problem is even worse as it appears even in scripts launched from the terminal with the environment managed by uv.

My questions are the following (I tried to look at the source code but couldn’t figure out the answers):

  • How does torchaudio links to the sox backend?
  • In what conditions does torchaudio.list_audio_backends() return an empty list even though shutil.which("sox") returns the path to sox properly?

Thank you for your help :pray: