Page MenuHome

Disable Python Environment Use (by default)
ClosedPublic

Authored by Campbell Barton (campbellbarton) on Jan 16 2020, 11:11 AM.

Details

Summary

This patch changes the behavior of Blender to ignore Python environment variables by default.

The main reason to do this is users sometimes have PYTHONPATH set to an incompatible Python version, causing Blender to fail to start.
Although the cause isn't obvious, and can take a while to track down, see: T72807: Blender does not open, T35800: Blender 2.67b crashes on startup (PYTHONPATH), T71768: Unable to start Blender, T33072: Blender 2.64 crashes on startup, T48889: Blender crashes if Python 2.7 is installed at C:\Python27,

For a while we overwrote the Python-path however this was a problem for Python developers who wanted to point Blender to their own Python installation and use local modules.

This patch removes the use of all Python environment variables by default. Python developers may override this behavior by passing the argument --python-use-system-env.

Diff Detail

Repository
rB Blender
Branch
TEMP-PY-ENV-DEFAULT-OFF (branched from master)
Build Status
Buildable 6272
Build 6272: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) retitled this revision from Default Python environment use to off to Disable Python Environment Use (by default).Jan 16 2020, 12:04 PM

Can confirm this fixes the repro i had for T72807.

This revision is now accepted and ready to land.Jan 16 2020, 3:29 PM
source/blender/python/intern/bpy_interface.c
97

nitpicking: static ?

LGTM, though I wonder, what happens when you build/install Blender without installing python (WITH_PYTHON_INSTALL disabled in CMake)? Will Blender still automatically 'switch' to system python then, as it does currently?

LGTM, though I wonder, what happens when you build/install Blender without installing python (WITH_PYTHON_INSTALL disabled in CMake)? Will Blender still automatically 'switch' to system python then, as it does currently?

This works without issues (using system Python here).

Python knows how to find it's own libraries (Python can run without PYTHONPATH). This could be an issue if you depended on a portable non-system Python in a custom location, although if you build and install your own Python, you normally don't move it around afterwards.

Great, think this can go in then. :)

veprbl added a subscriber: veprbl.Feb 29 2020, 6:47 PM
veprbl added inline comments.
source/creator/creator_args.c
682

Perhaps, it doesn't make sense to advertise this one anymore. It is ignored by default now.