"ModuleNotFoundError: No module named 'bpy_types'" when building as Python module #58069
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#58069
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've been trying to build Blender as a Python module, and keep running into the same error on both Mac and windows on both master and Blender2.8. I follow the build instructions on the wiki and updating CMakeLists.txt according to this BSO answer. Here is the most recent output after running
make update && make
just now on macOS Mojave:Surrounding the import statement with
try:catch:
doesn't do anything, crashing instead of throwing a python error. I've tried building blender normally and that does succeed, and I am able to importbpy
and everything else without a problem within the scripting console. This is true on both Mac and Windows. I've tried adding thescripts/modules
folder tosys.path
but this does not do anything.Added subscriber: @brhumphe
Added subscribers: @ideasman42, @mont29
@ideasman42 think you are still maintaining that experimental feature? ;)
Changed status from 'Open' to: 'Archived'
@mont29, yes.
@brhumphe you need to 'make install'. manually copying
bpy.so
will give this error.closing.
@ideasman42 Using
make install
does not fix the issue. I just did a fresh build and the results were the same:I created a virtual environment using these instructions from @dr.sybren , sim linking both
blender/release
andboy.so
inside of thesite-packages
directory of the virtual environment:Attempting to import bpy results in the following:
This may be OSX spesific then.
Try using a system call tracing tool (strace on Linux), to see which directories are being checked for immediately before the message:
bpy: couldnt find 'scripts/modules', blender probably wont start.
This is not OSX-specific, I have the same issue on Windows too, most recently with build 84285c1e3440. Here is the system trace from Procmon on windows: failed_bpy_import.CSV
@brhumphe On windows it's looking for:
C:\ProgramData\Blender Foundation\Blender\2.79\scripts\modules
This is from Blender's
release/scripts
path.Why is it looking there instead of searching the
sys.path
of the python interpreter?@brhumphe
I rather not get into details of why Blender is setup the way it is.
In brief, this works well for an application that embeds Python, but not so well for a Python module.
This can be made to work as long as the install target copies files to the correct locations. If you get this working, it'd be good to apply changes to CMake.
I keep this working on my system. The reason this bug remains closed is this feature is experimental and difficult to properly support - when Python devs run into issues.
@ideasman42 Fair enough. I can see how changing it to work with
sys.path
could be more effort than it’s worth. It’s good to know what the issue is, this was bugging me for weeks! If I find a solution I’ll pass it along.Added subscriber: @doppioslash
Added subscriber: @ankitm
Changed status from 'Archived' to: 'Resolved'
The error is because of the wrong command on the wiki.
It should be similar for Blender.app which is
Blender.app/Contents/Resources/2.93/scripts/addons
. For python modules it should look likelib/python3.9/Resources/2.93/scripts/addons
. The old command on the wiki producedlib/python3.9/Resources/scripts/addons
.Windows wiki was updated for this in November, macOS was updated just now.