Skip to content

Best way to distinguish between fake bpy and real bpy? #289

Closed Answered by Andrej730
Andrej730 asked this question in Q&A
Discussion options

You must be logged in to vote

This snippet seems to work:

try:
    import bpy

    # Ensure it's not fake-bpy-module.
    if not hasattr(bpy, "context"):
        raise ModuleNotFoundError
    BPY_IS_LOADED = True
except ModuleNotFoundError:
    BPY_IS_LOADED = False

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Andrej730
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant