Why is Blender not using the user's Path for this addon?

I’ve created an addon which is causing an issue on one user’s machine. The problem is that the addon relys on a Python library that requires the ffmpeg binary to be on the user’s path. For some reason, Blender is not using the user’s path even though the user has set up their path to include the directory where they have ffmpeg installed. The addon only works for them if they manually add the directory to the path in Blender’s python console and then reimport the Whisper library.

The user’s computer is a Mac. Any idea why this would be happening?

You wrote user path… do you mean PYTHONPATH ?? …

See also Docs-Blender Manual: info_tips_and_tricks → PYTHONPATH

No. Ffmpeg is not a python library but a regular binary app that should be available on the command line. While Whisper is a python module, it is making a command line call to try to run the ffmpeg program.

Ahh… yes… i was puzzled because of Python library… ( and overread ffmpeg binary :sweat_smile: )…

I’m not sure if blender (or the embedded python) is using the PATH variable to execute any binary via the subprocess library call… :thinking:

It works for most users, including on my Windows machine. This is the first report I’ve got of this, and I don’t know much about Macs.

Oh… that’s strange… ffmpeg is in the standard location and can be called via the command line ? If not then maybe there is something wrong (typo) with the PATH var…

I’m no sure if apple does have/use any extra safty mechanism like for example not exporting the PATH variable after calling an app ?? So blender is called but can’ execute any further process ( yeah a really strange idea… but maybe… :green_apple: … you know… :wink: ) ??

Looking at his github issue, your user found this with ChatGPT:

`import os
os.environ['PATH'] += os.pathsep + '/usr/local/bin'

from whisper.audio import load_audio # Ensure this is after setting PATH

# Your existing code

While I generally wouldn’t trust ChatGPT to code anything, apparently adding this in the Blender console worked for him. I’d suggest having him try each of those imports in separate instances of the blend file to see if the problem is the path or the whisper audio, or both.

Either way, it seems that your addon is not importing something properly for his environment. Could be a mac issue and he’s just the first mac user to actually flag it or it could be he just has a weird setup, but revisiting your import code based on his results and seeing if you can make it more robust wouldn’t hurt.

1 Like

That’s definiively weird if ffmpeg is installed on /usr/local/bin and this is also already in the PATH variable and after adding it “again”…
…but havin a furter look on github:
There is also /usr/local/Cellar/ffmpeg/7.0.1/bin before /usr/local/bin. This also “should not b e the problem” when installing some special lib this way… but… :person_shrugging: