"ImportError: sys.meta_path is None, Python is likely shutting down" on exit when built as a Python module #82675

Closed
opened 2020-11-13 00:30:40 +01:00 by Tyler Alden Gubala · 20 comments

System Information
Operating system: MacOS
Graphics card: Intel Integrated

Blender Version
Broken: 2.91

Short Description of the Problem
When built as a Python module, on exiting the Python process you will get the following error:

ImportError: sys.meta_path is None, Python is likely shutting down
Error: Unknown py-exception, could not convert
zsh: segmentation fault  python3

Exact steps for others to reproduce the error

  1. Get Python 3.7.9 from Python.org (not brew)
  2. mkdir bpy-test
  3. cd bpy-test
  4. curl -L https://github.com/TylerGubala/blenderpy/releases/download/v2.91a0/bpy-2.91a0-cp37-cp37m-macosx_10_13_x86_64.whl
  5. python3 -m venv venv
  6. source venv/bin/activate
  7. python3 -m pip install -U pip setuptools wheel
  8. python3 -m pip install bpy-2.91a0-cp37-cp37m-macosx_10_13_x86_64.whl && bpy_post_install
  9. python3 -c 'import bpy;bpy.ops.render.render(write_still=True)'

See: https://github.com/TylerGubala/blenderpy/issues/60
See also: https://devtalk.blender.org/t/bpy-obscure-error-during-python-exit-on-macos/16102

**System Information** Operating system: MacOS Graphics card: Intel Integrated **Blender Version** Broken: 2.91 **Short Description of the Problem** When built as a Python module, on exiting the Python process you will get the following error: ``` ImportError: sys.meta_path is None, Python is likely shutting down Error: Unknown py-exception, could not convert zsh: segmentation fault python3 ``` **Exact steps for others to reproduce the error** 1. Get [Python 3.7.9 from Python.org](https://www.python.org/ftp/python/3.7.9/python-3.7.9-macosx10.9.pkg) (**not** `brew`) 2. `mkdir bpy-test` 3. `cd bpy-test` 4. `curl -L https://github.com/TylerGubala/blenderpy/releases/download/v2.91a0/bpy-2.91a0-cp37-cp37m-macosx_10_13_x86_64.whl` 5. `python3 -m venv venv` 6. `source venv/bin/activate` 7. `python3 -m pip install -U pip setuptools wheel` 8. `python3 -m pip install bpy-2.91a0-cp37-cp37m-macosx_10_13_x86_64.whl && bpy_post_install` 9. `python3 -c 'import bpy;bpy.ops.render.render(write_still=True)'` See: https://github.com/TylerGubala/blenderpy/issues/60 See also: https://devtalk.blender.org/t/bpy-obscure-error-during-python-exit-on-macos/16102

Added subscriber: @TylerGubala

Added subscriber: @TylerGubala

Added subscriber: @grzelins

Added subscriber: @grzelins

I can confirm this problem on current (13.11) master (4efd87d56b65e4fb5c10de399ab15ef59a9c305f)

Platform: windows: ** Visual Studio 2019 Developer Command Prompt v16.7.6

make update
make bpy
# copy bpy to python site packages and so on

C:\Users\mat-lp\Documents\blender-src\blender>python
Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import bpy
>>> bpy.app.version_string

'2.92.0 Alpha'

>>> exit()

ImportError: sys.meta_path is None, Python is likely shutting down
Error: Unknown py-exception, could not convert

This error also causes debugging traps to fail in pycharm.

btw. I just noticed that operators bpy.ops.wm.url_open_preset(type='BUG') and bpy.ops.wm.sysinfo() does not work in this setup (fail with python traceback)...

I can confirm this problem on current (13.11) master (`4efd87d56b65e4fb5c10de399ab15ef59a9c305f`) Platform: **windows**: `** Visual Studio 2019 Developer Command Prompt v16.7.6` ``` make update make bpy # copy bpy to python site packages and so on C:\Users\mat-lp\Documents\blender-src\blender>python Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import bpy >>> bpy.app.version_string '2.92.0 Alpha' >>> exit() ImportError: sys.meta_path is None, Python is likely shutting down Error: Unknown py-exception, could not convert ``` This error also causes debugging traps to fail in pycharm. btw. I just noticed that operators `bpy.ops.wm.url_open_preset(type='BUG')` and `bpy.ops.wm.sysinfo()` does not work in this setup (fail with python traceback)...

Added subscriber: @rjg

Added subscriber: @rjg

In my recent build of bpy, I can reproduce this error message when calling exit(). I'll have to check where this is coming from.

In my recent build of bpy, I can reproduce this error message when calling `exit()`. I'll have to check where this is coming from.

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

Do you know which most recent version worked properly?

Do you know which most recent version worked properly?

Changed status from 'Needs User Info' to: 'Confirmed'

Changed status from 'Needs User Info' to: 'Confirmed'

Known good commit is fd5d014b62, will try to bisect.

Known good commit is fd5d014b62, will try to bisect.

Added subscriber: @ideasman42

Added subscriber: @ideasman42

This was issue was introduced in commit fa566157a5 where the Python modules are unregistered on exit (CC @ideasman42).

This was issue was introduced in commit fa566157a5 where the Python modules are unregistered on exit (CC @ideasman42).
Member

Added subscriber: @plasmasolutions

Added subscriber: @plasmasolutions

Added subscriber: @Cora-Lina

Added subscriber: @Cora-Lina

A quick workaround is to go inside ./blender/source/blender/windowmanager/intern and the edit wm_init_exit.c , and comment the line BPY_run_string_eval(C, (const char *- [ ]){"addon_utils", NULL}, "addon_utils.disable_all()");

A quick workaround is to go inside ./blender/source/blender/windowmanager/intern and the edit wm_init_exit.c , and comment the line BPY_run_string_eval(C, (const char *- [ ]){"addon_utils", NULL}, "addon_utils.disable_all()");

Changed status from 'Confirmed' to: 'Needs User Info'

Changed status from 'Confirmed' to: 'Needs User Info'

While I can't redo this error, I ran into a different error which might have caused this bug too f35a38fba7.

Could you check if this fixes the problem?

While I can't redo this error, I ran into a different error which might have caused this bug too f35a38fba7. Could you check if this fixes the problem?

The problem is not fixed, the same error still occurs.

The problem is not fixed, the same error still occurs.

Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'

Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'

This issue was referenced by 87d3f4aff3

This issue was referenced by 87d3f4aff3225104cbb8be41ac0339c6a1cd9a85

Changed status from 'Needs Developer To Reproduce' to: 'Resolved'

Changed status from 'Needs Developer To Reproduce' to: 'Resolved'
Campbell Barton self-assigned this 2021-01-28 04:56:23 +01:00
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
7 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#82675
No description provided.