Page MenuHome

Blender sys.path is different when opened via MacOS icon
Closed, ArchivedPublic

Description

System Information
Operating system: MacOS 10.14.6
Graphics card:

Blender Version
Broken: 2.80
Worked: (optional)

Short description of error
When Blender is opened by clicking on the Blender.app icon, the underlying system path (accessed via "import os; os.environ['PATH']" in the console) is not the same as the user's path, which is inconsistent with the behavior when Blender is opened via double clicking Blender.app/Contents/MacOS/Blender. This causes problems for addons when trying to call external programs.

Note that this only happens on MacOS and not on Ubuntu.

Exact steps for others to reproduce the error
Open blender by clicking on Blender.app.
Go to Scripting.
Type "import os; os.environ['PATH']" in the Console.
Returns "/usr/bin:/bin:/usr/sbin:/sbin"

Open blender by going to Blender.app/Contents/MacOS/Blender
Go to scripting
Type "import os; os.environ['PATH']" in the Console
Returns user's path.

Event Timeline

Brecht Van Lommel (brecht) changed the task status from Unknown Status to Unknown Status.Oct 8 2019, 10:23 AM
Brecht Van Lommel (brecht) claimed this task.

This is how macOS works for all apps. They are not launched in an environment that reads .profile and similar.
https://www.google.com/search?q=macos+app+path+environment+variable

I don't think this is something we should try to work around in Blender. You may be able to launch a shell and extract out environment variables, but probably shouldn't rely on PATH.