New Windows install, multiple Blender versions crash: EXCEPTION_ACCESS_VIOLATION (Python 3.12.0 conflict?) #115648

Open
opened 2023-12-01 07:42:25 +01:00 by Nazo · 5 comments

System Information
Operating system: Windows 10 Professional 22H2
Graphics card: nVidia Geforce RTX 3060Ti (8GB)

Short description of error
Shortest description: as long as the PYTHONPATH variable is set it crashes instantly on start with EXCEPTION_ACCESS_VIOLATION Unsetting it allows it to start (but breaks other things using the installed Python.)

Long version: I recently reinstalled Windows to resolve some unrelated issues. This is the same version of Windows, but of course I reinstalled all sorts of things including Python (3.12.0 was current at the time I downloaded it.) That also includes the latest graphics drivers (though as it turns out that is unrelated.) I originally tried Blender 3.1.0 as that's just what I had handy (I kept it portable,) then I updated to the latest, but it still crashed. I also tried an install though I prefer to keep it portable and that didn't work either. As per the other recent threads with the same error message I tried one of the dev builds and the resource candidate, but they all crashed too. However, I noticed the .cmd files to try various debug options and tried them. They all worked. I got suspicious and looked at the files. They all start with SET PYTHONPATH= to clear the Python variable. As it turns out that is the only thing required to make it start -- no other debug mitigations needed. If I open a terminal there, clear PYTHONPATH, and then run Blender it just works without a crash. I also tried it with a portable Python 3.10 (not venv) configuration and that worked too without clearing the variable (the portable Python has its own PYTHONPATH variable pointing to its own binaries and scripts.)

I don't know if it might be some sort of conflict with Python 3.12.0 or something else, but regardless, clearing PYTHONHOME before starting Blender (or using a portable Python 3.10) works every time.

Exact steps for others to reproduce the error
Presumably install Python 3.12.0 and then run this.

**System Information** Operating system: Windows 10 Professional 22H2 Graphics card: nVidia Geforce RTX 3060Ti (8GB) **Short description of error** Shortest description: as long as the PYTHONPATH variable is set it crashes instantly on start with EXCEPTION_ACCESS_VIOLATION Unsetting it allows it to start (but breaks other things using the installed Python.) Long version: I recently reinstalled Windows to resolve some unrelated issues. This is the same version of Windows, but of course I reinstalled all sorts of things including Python (3.12.0 was current at the time I downloaded it.) That also includes the latest graphics drivers (though as it turns out that is unrelated.) I originally tried Blender 3.1.0 as that's just what I had handy (I kept it portable,) then I updated to the latest, but it still crashed. I also tried an install though I prefer to keep it portable and that didn't work either. As per the other recent threads with the same error message I tried one of the dev builds and the resource candidate, but they all crashed too. However, I noticed the .cmd files to try various debug options and tried them. They all worked. I got suspicious and looked at the files. They all start with SET PYTHONPATH= to clear the Python variable. As it turns out that is the only thing required to make it start -- no other debug mitigations needed. If I open a terminal there, clear PYTHONPATH, and then run Blender it just works without a crash. I also tried it with a portable Python 3.10 (not venv) configuration and that worked too without clearing the variable (the portable Python has its own PYTHONPATH variable pointing to its own binaries and scripts.) I don't know if it might be some sort of conflict with Python 3.12.0 or something else, but regardless, clearing PYTHONHOME before starting Blender (or using a portable Python 3.10) works every time. **Exact steps for others to reproduce the error** Presumably install Python 3.12.0 and then run this.
Nazo added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-12-01 07:42:26 +01:00
Iliya Katushenock added the
Interest
Python API
label 2023-12-01 08:37:15 +01:00

It appears to be one of the cases "where the systems Python is inexplicably used" (as mentioned in ebb492a389)

Apparently same happened in #98131

@LazyDodo and @ideasman42 seem to have invested that case.

I tried to replicate setting the PYTHONPATH to a Python 3.11.5 executable, but Blender continues to use the one included in it (3.10.13).

It appears to be one of the cases "where the systems Python is inexplicably used" (as mentioned in ebb492a389) Apparently same happened in #98131 @LazyDodo and @ideasman42 seem to have invested that case. I tried to replicate setting the PYTHONPATH to a Python 3.11.5 executable, but Blender continues to use the one included in it (3.10.13).
Author

Ah, I tried to search, but didn't spot those. The only thing I can think of to add that might be useful is that 1. My python script directory is in my path so I can run things from a normal command prompt (eg pip/etc) and 2. I was having troubles with just the defaults so had added more to the PYTHONPATH variable (namely it seems to want multiple locations to point to library folders and such.) My current PYTHONPATH variable: PYTHONPATH=C:\Python312;C:\Python312\Lib;C:\Python312\DLLs;C:\Python312\Lib\lib-tk;C:\Python312\Scripts

I wonder if Blender just prefixes the variable with its own path, but perhaps doesn't override the full thing? (Eg PYTHONPATH=%CD%\Whatever;%PYTHONPATH% ) Ideally it should just straight up replace each variable with its own within its environment to avoid conflicts.

Ah, I tried to search, but didn't spot those. The only thing I can think of to add that might be useful is that 1. My python script directory is in my path so I can run things from a normal command prompt (eg pip/etc) and 2. I was having troubles with just the defaults so had added more to the PYTHONPATH variable (namely it seems to want multiple locations to point to library folders and such.) My current PYTHONPATH variable: PYTHONPATH=C:\Python312;C:\Python312\Lib;C:\Python312\DLLs;C:\Python312\Lib\lib-tk;C:\Python312\Scripts I wonder if Blender just prefixes the variable with its own path, but perhaps doesn't override the full thing? (Eg PYTHONPATH=%CD%\Whatever;%PYTHONPATH% ) Ideally it should just straight up replace each variable with its own within its environment to avoid conflicts.

@Nazo the PYTHONPATH should not be used unless you pass --python-use-system-env to Blender.

So if the PYTHOHNPATH is interfering with Blender's startup, that's something that should be fixed.

@Nazo the PYTHONPATH should not be used unless you pass `--python-use-system-env` to Blender. So if the PYTHOHNPATH is interfering with Blender's startup, that's something that should be fixed.

For me PYTHONPATH is interfering with Blender's startup. The only workaround is to launch with a batch file that returns an empty path.

https://blender.stackexchange.com/questions/316531/how-to-use-blenders-internal-python-version-libraries-with-pythonpath-env-in-us/316588#316588

For me `PYTHONPATH` is interfering with Blender's startup. The only workaround is to launch with a batch file that returns an empty path. https://blender.stackexchange.com/questions/316531/how-to-use-blenders-internal-python-version-libraries-with-pythonpath-env-in-us/316588#316588

@ideasman42 The last time sys.flags.ignore_environment is 1 is in 2.83. I think a misconfiguration going on in https://github.com/blender/blender/blame/main/source/blender/python/intern/bpy_interface.cc BPY_python_start.

PyPreConfig_InitIsolatedConfig is used for PyPreConfig depending on py_use_system_env but PyConfig is using PyConfig_InitPythonConfig for Py_InitializeFromConfig. So isolated is 0 and use_environment is 1.

I set use_environment to 0 via the Visual Studio Debugger and my PYTHONPATH does not appear in sys.path.

image

@ideasman42 The last time `sys.flags.ignore_environment` is `1` is in `2.83`. I think a misconfiguration going on in https://github.com/blender/blender/blame/main/source/blender/python/intern/bpy_interface.cc `BPY_python_start`. `PyPreConfig_InitIsolatedConfig` is used for `PyPreConfig` depending on `py_use_system_env` but `PyConfig` is using `PyConfig_InitPythonConfig` for `Py_InitializeFromConfig`. So `isolated` is `0` and `use_environment` is `1`. I set `use_environment` to `0` via the Visual Studio Debugger and my `PYTHONPATH` does not appear in `sys.path`. ![image](/attachments/cf6da308-26e6-4207-ae04-547fd7891b08)
168 KiB
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#115648
No description provided.