UV Layout: 'export_layout' operator doesn't run because GPU functions are not available in background mode #98167

Open
opened 2022-05-16 16:34:36 +02:00 by benhoyle · 7 comments

System Information
Operating system: Windows11 64 bits, ubuntu

Blender Version
Broken: nytimes/blender:3.1-cpu-ubuntu18.04
Worked: Never

Addon Information
Name: UV Layout (1, 1, 1)
Author: Campbell Barton, Matt Ebb

Short description of error
Error with bpy.ops.uv.export_layout() when trying to write UVs to a file.

Error: Python: Traceback (most recent call last):
  File "D:\BlenderDev\x64-Release\bin\RelWithDebInfo\3.3\scripts\addons\io_mesh_uv_layout\__init__.py", line 139, in execute
    export(filepath, polygon_data, different_colors, self.size[0], self.size[1], self.opacity)
  File "D:\BlenderDev\x64-Release\bin\RelWithDebInfo\3.3\scripts\addons\io_mesh_uv_layout\export_uv_png.py", line 13, in export
    offscreen = gpu.types.GPUOffScreen(width, height)
SystemError: GPU functions for drawing are not available in background mode

Exact steps for others to reproduce the error

  • In a console just run: blender.exe --background --python-expr "import bpy; bpy.ops.uv.export_layout()"
**System Information** Operating system: Windows11 64 bits, ubuntu **Blender Version** Broken: nytimes/blender:3.1-cpu-ubuntu18.04 Worked: Never **Addon Information** Name: UV Layout (1, 1, 1) Author: Campbell Barton, Matt Ebb **Short description of error** Error with `bpy.ops.uv.export_layout()` when trying to write UVs to a file. ``` Error: Python: Traceback (most recent call last): File "D:\BlenderDev\x64-Release\bin\RelWithDebInfo\3.3\scripts\addons\io_mesh_uv_layout\__init__.py", line 139, in execute export(filepath, polygon_data, different_colors, self.size[0], self.size[1], self.opacity) File "D:\BlenderDev\x64-Release\bin\RelWithDebInfo\3.3\scripts\addons\io_mesh_uv_layout\export_uv_png.py", line 13, in export offscreen = gpu.types.GPUOffScreen(width, height) SystemError: GPU functions for drawing are not available in background mode ``` **Exact steps for others to reproduce the error** - In a console just run: `blender.exe --background --python-expr "import bpy; bpy.ops.uv.export_layout()"`
Author

Added subscriber: @benhoyle1212

Added subscriber: @benhoyle1212

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Well, even working offscreen, the GPU module does not work in background mode because in this mode a drawing context is not created.
So it's not something with a simple solution.
You need to create a temporary window if you really need to run this operator.

But Error: Python: Traceback doesn't seem ideal, therefore confirming the bug.

Well, even working offscreen, the GPU module does not work in background mode because in this mode a drawing context is not created. So it's not something with a simple solution. You need to create a temporary window if you really need to run this operator. But `Error: Python: Traceback` doesn't seem ideal, therefore confirming the bug.
Germano Cavalcante changed title from GPU functions for drawing are not available in background mode : Docker-container Ubuntu 18.04 blender 3.10 to UV Layout: 'export_layout' operator doesn't run because GPU functions are not available in background mode 2022-05-19 21:19:37 +02:00

Added subscriber: @phil123456

Added subscriber: @phil123456

FYI : I have the same issue installing MY addon while the problem comes form the official Anim Extras addon
(workaround : disabled animextras - install my script - enable animextras)

"P:\Program Files\Blender Foundation\Blender 3.1\blender.exe" --background --python __init__.py
Blender 3.1.2 (hash cc66d1020c3b built 2022-03-31 23:39:57)
Read prefs: C:\Users\phil\AppData\Roaming\Blender Foundation\Blender\3.1\config\userpref.blend
Traceback (most recent call last):
  File "P:\Program Files\Blender Foundation\Blender 3.1\3.1\scripts\modules\addon_utils.py", line 351, in enable
    mod = __import__(module_name)
  File "C:\Users\phil\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\animextras-main\__init__.py", line 40, in <module>
    from .ons.gui import *
  File "C:\Users\phil\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\animextras-main\ons\gui.py", line 6, in <module>
    from .ops import *
  File "C:\Users\phil\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\animextras-main\ons\ops.py", line 19, in <module>
    shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
SystemError: GPU functions for drawing are not available in background mode
importing .py files
FYI : I have the same issue installing MY addon while the problem comes form the official Anim Extras addon (workaround : disabled animextras - install my script - enable animextras) ``` "P:\Program Files\Blender Foundation\Blender 3.1\blender.exe" --background --python __init__.py ``` ``` Blender 3.1.2 (hash cc66d1020c3b built 2022-03-31 23:39:57) Read prefs: C:\Users\phil\AppData\Roaming\Blender Foundation\Blender\3.1\config\userpref.blend Traceback (most recent call last): File "P:\Program Files\Blender Foundation\Blender 3.1\3.1\scripts\modules\addon_utils.py", line 351, in enable mod = __import__(module_name) File "C:\Users\phil\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\animextras-main\__init__.py", line 40, in <module> from .ons.gui import * File "C:\Users\phil\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\animextras-main\ons\gui.py", line 6, in <module> from .ops import * File "C:\Users\phil\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\animextras-main\ons\ops.py", line 19, in <module> shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') SystemError: GPU functions for drawing are not available in background mode importing .py files ```

Is there an alternative to uv.export_layout that wouldn't require the gui? All the maths is being done under the hood anyway, is it not possible to access it without the gui?

Is there an alternative to uv.export_layout that wouldn't require the gui? All the maths is being done under the hood anyway, is it not possible to access it without the gui?
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 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-addons#98167
No description provided.