I compiled Blender as a Python module successfully under Windows.
Then I tried to use bpy to make a simple plot inside my Python program.
This program is run under Liclipse with a Python 3.7 installation to deal with Blender Python 3.7 version.
The path to bpy module is added in PyDev - PYTHONPATH / External Libraries.
But in my Python script the line ‘import bpy’ leads to the following error:
C:\blender-git\build_windows_x64_vc16_Release_bpy\bin\Release\2.91\scripts\modules\bpy\__init__.py", line 38, in <module>
from _bpy import (
ModuleNotFoundError: No module named '_bpy'
Why does bpy module code contain this kind of syntax ‘from _bpy import …’ ?
How can we deal with that to make bpy work ?
Maybe the installation of Blender as a Python module is incomplete. Did you follow all of the steps from this guide to create a Python installation with the bpy module in it?
You can verify if this worked by simply running a python shell from the python folder you have installed the bpy module to, and enter import bpy there. It should not throw any errors.
Thanks for your reply.
Firstly I just added bpy path to PyDev - PYTHONPATH / External Libraries in Liclipse.
Then I followed all requirements as you adviced : copy of bpy.pyd + *.dll in Python37\lib\site-packages, copy of 2.91 in Python37.
Now I get the following error:
import bpy
ImportError: DLL load failed: L’application n’a pas pu démarrer car sa configuration côte-à-côte est incorrecte. Pour plus d’informations, consultez le journal des événements des applications ou utilisez l’outil de ligne de commande sxstrace.exe.
This post said it’s fixed but is it really ?
After recompiling with WITH_WINDOWS_BUNDLE_CRT to OFF it went a step forward:
Color management: using fallback mode for management
Color management: Error could not find role data role.
BLT_lang_init: ‘locale’ data path for translations not found, continuing
Color management: scene view “Filmic” not found, setting default “Standard”.
blf_load_font_default: ‘fonts’ data path not found for ‘droidsans.ttf’, will not be able to display text
blf_load_font_default: ‘fonts’ data path not found for ‘bmonofont-i18n.ttf’, will not be able to display text
blf_load_font_default: ‘fonts’ data path not found for ‘bmonofont-i18n.ttf’, will not be able to display text
bpy: couldn’t find ‘scripts/modules’, blender probably wont start.
Freestyle: couldn’t find ‘scripts/freestyle/modules’, Freestyle won’t work properly.
Same error if I run “import bpy” in a python shell.
In fact I am not sure if it was a step forward or backward…
Thus I added datafiles and scripts paths in PyDev - PYTHONPATH / External Libraries in Liclipse and I got again this error:
ModuleNotFoundError: No module named ‘_bpy’
I recall having had the windows SideBySide error you got as well some time ago. IIRC the reason back then had been that the make bpy command did not finish without errors. Can you verify that make bpy works on your configuration? It’s a good idea to do a fresh recompile, meaning renaming or deleting the whole build folder first.