ModuleNotFoundError: No module named 'material_recommender'
I created a new anaconda environment, installed the packages listed in the README file and verified that importing each of them worked, and then linked the new conda environment with Blender. Unfortunately, when I try to install "material_recommender-master.zip" as an add-on in Blender, it fails with the following traceback:
Traceback (most recent call last):
File "/home/trevor/Pictures/blender/blender-2.83.8-linux64/2.83/scripts/modules/addon_utils.py", line 351, in enable
mod = __import__(module_name)
File "/home/trevor/.config/blender/2.83/scripts/addons/material_recommender-master/__init__.py", line 23, in <module>
from . operators.preferences.generator import PreferencesListGenerator
File "/home/trevor/.config/blender/2.83/scripts/addons/material_recommender-master/operators/preferences/generator.py", line 3, in <module>
from material_recommender.gms import cnn
ModuleNotFoundError: No module named 'material_recommender'
I don't remember doing this, but I might have installed the package as an editable package with pip beforehand so that python can find it. The other option would be to add some code to add the package path to python's path. Hmm, but I did that here: https://github.com/vladvrabie/material_recommender/blob/0565dbff3ef7e6934897d85cd41f8bec1c771919/init.py#L16
Hello, I followed the same procedure and I have the same issue.
Could you explain further the way to correct that ?
Thanks !
Hey, I'm sorry this still is a problem. When I wrote the project, the above solution worked for me, although it's not the cleanest. To solve this self import problem, I can think of two options:
- in
material_recommender/__init__.pymaybe also including the parent of the current folder?sys.path.append(os.path.abspath('..'))I am not sure if this will work and might be the dirtiest option. - refactor absolute imports (
from material_recommender import ...) to relative imports (from . import ...) By some Python coding guidelines, I know this is also not popular/desirable, but I don't see another option.
If you try either option and it works/fails, please let me know :)