mitsuba-renderer / mitsuba3

Mitsuba 3: A Retargetable Forward and Inverse Renderer
https://www.mitsuba-renderer.org/
Other
1.99k stars 227 forks source link

Compiling problems in python using #1203

Open EarlyForGimlet opened 2 months ago

EarlyForGimlet commented 2 months ago

Description

i am afraid i am not very familiar with the compiling issue, i changed my mitsuba.conf with the following :

    "enabled": [
        "scalar_rgb", "scalar_spectral", "cuda_ad_rgb", "llvm_ad_rgb","scalar_spectral_polarized","cuda_rgb_polarized","cuda_mono_polarized"
    ],

and then i compiled it following the guide, there is only one error but doesn't seem matter, however when i use the setpath.bat nothing happened, and i can't find the mitsuba3.exe neither, i just wanna to know how to use the compiled mitsuba in python since i know that i don't need to use "pip install mitsuba" because it may cause some confusing problems according to the former Q&As, so what should i do after compiling and are my compling methods proper? thanks a lot!

njroussel commented 2 months ago

Running setpath.bat will add the build folder to PATH/PYTHONPATH environment variables. Once that is done you should be able to import mitsuba in your python shell.

Alternatively, you can ignore the setpath.bat script and in your python file add something along the lines of

import sys
sys.path.append("your/path/to/the/release/build/folder") 
import mitsuba

This is equivalent to adding the build folder to the PYTHONPATH environment variable.

EarlyForGimlet commented 2 months ago

thank you for your answers, i tried your ways and finally succeeded, however the mudule"mitsuba" is highlighed with underline image i still can print the following variants correctly ,which is a great progress for me 屏幕截图 2024-06-20 141436 i wonder to know how to solve this problem cause there is no automatic code completion which is a bit annoying what's more, when i import this mudule i found that i have to change my environment from conda env i established before into python's “oiginal environment” because it said that :

ImportError: The 'mitsuba' native modules could not be imported. You're likely trying to use Mitsuba within a Python binary (D:\ProgramFiles\Anaconda3\envs\mitsuba\python.exe) that is different from the one for which the native module was compiled (C:\Users\MSI\AppData\Local\Programs\Python\Python39\python.exe).

is there any solutions to compatible the compiled mitsuba with the conda env? thank you for your time and attention in this matter!

njroussel commented 2 months ago

That snippet of code makes Python aware of the mitsuba package at runtime. For you IDE to be able to give you auto-completion information, it also needs to add that path to its PYTHONPATH.Maybe your IDE has an option to add paths somewhere.

When you compiled mitsuba, were you in a conda env? I think that should work.