`torchaudio` fails to find sox backend even though sox is in PATH

Completed

I changed my M1 Pro macBook Pro for a brand new macbook M4 Pro yesterday.

I reinstalled everything, and everything is working except one annoying thing on my Python projects in PyCharm. I can't fingure output where the problem come from.

The problem is best described with the following simple script:
```
import torchaudio, shutil
print(shutil.which("sox"))
print(torchaudio.list_audio_backends())
```

After installing sox with brew, Python 3.10.16 with pyenv and building a venv and installing torchaudio with pip, I set the venv as the default interpreter for my project.

If I open the project and run the script from PyCharm terminal using `python my_scripts.py`, I have the following output:
```
/opt/homebrew/bin/sox
['sox']
```

If I run the same script from PyCharm “run current file” button in the UI, I have the following output:
```
/opt/homebrew/bin/sox
[]
```

In the last case, `sox` is indeed in the `PATH` as it is found by `shutil`, but `torchaudio` fails to instantiate its `sox` backend.

I verified that the same `Python` interpreter is used in both cases.    
Moreover, the problem was not there on my previous machine and I did not have to setup anything to make `torchaudio` work properly in PyCharm.   
Finally, I tested the same script in VSCode. After choosing the local venv interpreter, `sox` backend is initliatzed properly in `torchaudio`.

Do you have any idea where my problem could come from?

0
1 comment

Hi @Thomas , this issue requires thorough investigation, please create an issue on YouTrack using this link: https://youtrack.jetbrains.com/issues/PY, attach all relevant information for quicker resolution.

0

Post is closed for comments.