Skip to content

Mitsuba Package Installation: Failed to load Mitsuba Module (Blender 4.5) #143

@Microno95

Description

@Microno95

Issue Title
Failure to load Mitsuba module despite successful pip install due to changing search paths in Blender 4.5.

Bug Description
Mitsuba-Blender add-on fails to find Mitsuba module when running in Blender 4.5 on Windows as the mitsuba (and drjit) python packages are installed in the user-specific site-packages folder (%APPDATA%\Python\Python311\site-packages), but this folder is no longer included in the search path for Python packages as of (as far as I can tell) Blender 4.2.

To Reproduce
Steps to reproduce the behavior:

  1. Install add-on in Blender 4.5 on Windows
  2. Enable add-on and run Install Dependencies
  3. Failed to load mitsuba module error ensues despite successful installation pip log in Blender console.

Expected behavior
No error on failing to load the module.

Environment (please complete the following information):

  • OS: Windows
  • Blender Version: 4.5.0
  • Add-on Version: 0.4.0 (the add-on version shows up as 0.1 inside Blender btw)

Additional context
This can be fixed, following this thread on the Blender Stack-Exchange by additionally importing site as a module and adding the lines

user_site_pkgs = site.getusersitepackages()
if user_site_pkgs not in sys.path:
    sys.path.append(user_site_pkgs)

to the init_mitsuba function which ensures that the user-site packages path is automatically included in the search path for import mitsuba.

This is the simplest solution, but modifies the package search path globally so an alternative could be to only invoke this if/when Mitsuba fails to load and then remove the path from sys.path after Mitsuba is successfully imported - might break things with dynamic reloading of packages as Mitsuba does with switching variants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions