Python Wheels not working in Blender4.2

Hi everyone:

I followed the instruction at https://docs.blender.org/manual/en/4.2/advanced/extensions/python_wheels.html
to bundle Python wheels to my addon.

Here is a simple addon zip file I built:

In the addon I include the pillow wheel for windows, but when install the zip file, I keep getting "No module named 'PIL' error. The addon is added to the addon directory but it can not be enabled due to this error.

Wondering if there is anything wrong in my package?

My package structure looks like this

sample_addon
-- addons
-- common
-- wheels
    -- pillow-10.3.0-cp311-cp311-win_amd64.whl
-- __init__.py
-- blender_manifest.toml

I have included the following in the toml

wheels = [
    "./wheels/pillow-10.3.0-cp311-cp311-win_amd64.whl",
]

I am using the latest Blender 4.2 beta on Windows 11

Detailed logs:

addon_utils.disable: sample_addon not loaded
registering
Exception in module register(): C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\__init__.py
Traceback (most recent call last):
  File "C:\software\general\Blender\blender-4.2.0-beta\4.2\scripts\modules\addon_utils.py", line 462, in enable
    mod.register()
  File "C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\__init__.py", line 37, in register
    auto_load.init()
  File "C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\common\class_loader\auto_load.py", line 32, in init
    modules = get_all_submodules(Path(__file__).parent.parent.parent)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\common\class_loader\auto_load.py", line 69, in get_all_submodules
    return list(iter_submodules(directory, directory.name))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\common\class_loader\auto_load.py", line 74, in iter_submodules
    yield importlib.import_module("." + name, package_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\software\general\Blender\blender-4.2.0-beta\4.2\python\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\addons\sample_addon\operators\AddonOperators.py", line 2, in <module>
    import PIL
ModuleNotFoundError: No module named 'PIL'
错误: No module named 'PIL'
Traceback (most recent call last):
  File "C:\software\general\Blender\blender-4.2.0-beta\4.2\scripts\addons_core\bl_pkg\bl_extension_ops.py", line 1121, in execute
    cmd_batch = self.exec_command_iter(is_modal)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\software\general\Blender\blender-4.2.0-beta\4.2\scripts\addons_core\bl_pkg\bl_extension_ops.py", line 1991, in exec_command_iter
    self.exec_legacy(source_filepath)
  File "C:\software\general\Blender\blender-4.2.0-beta\4.2\scripts\addons_core\bl_pkg\bl_extension_ops.py", line 2094, in exec_legacy
    bpy.types.PREFERENCES_OT_addon_install.execute(self, bpy.context)
  File "C:\software\general\Blender\blender-4.2.0-beta\4.2\scripts\startup\bl_operators\userpref.py", line 765, in execute
    bpy.ops.preferences.addon_enable(module=mod.__name__)
  File "C:\software\general\Blender\blender-4.2.0-beta\4.2\scripts\modules\bpy\ops.py", line 109, in __call__
    ret = _op_call(self.idname_py(), kw)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 错误: No module named 'PIL'

registering
Exception in module register(): C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\__init__.py
Traceback (most recent call last):
  File "C:\software\general\Blender\blender-4.2.0-beta\4.2\scripts\modules\addon_utils.py", line 462, in enable
    mod.register()
  File "C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\__init__.py", line 37, in register
    auto_load.init()
  File "C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\common\class_loader\auto_load.py", line 32, in init
    modules = get_all_submodules(Path(__file__).parent.parent.parent)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\common\class_loader\auto_load.py", line 69, in get_all_submodules
    return list(iter_submodules(directory, directory.name))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\common\class_loader\auto_load.py", line 74, in iter_submodules
    yield importlib.import_module("." + name, package_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\software\general\Blender\blender-4.2.0-beta\4.2\python\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\xzhua_btbm7dw\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\sample_addon\addons\sample_addon\operators\AddonOperators.py", line 2, in <module>
    import PIL
ModuleNotFoundError: No module named 'PIL'

I haven’t had the chance to test your addon or repo yet, but I did see a bug report that you might want to check out regarding wheels not being installed when they should: https://projects.blender.org/blender/blender/issues/123645

It might just be a bug that the Blender developers need to fix.

1 Like