简体   繁体   中英

How to fix error when importing the blender module in Python

i get the following error code when i import bpy into python is this because i need blender installed or can i solve this probelm another way'

Color management: using fallback mode for management
BLT_lang_init: 'locale' data path for translations not found, continuing
AL lib: (EE) UpdateDeviceParams: Failed to set 44100hz, got 48000hz instead
bpy: couldnt find 'scripts/modules', blender probably wont start.
Freestyle: couldn't find 'scripts/freestyle/modules', Freestyle won't work properly.
ModuleNotFoundError: No module named 'bpy_types'
ModuleNotFoundError: No module named 'bpy_types'
ERROR (bpy.rna): c:\users\tgubs\.blenderpy\blender\source\blender\python\intern\bpy_rna.c:6662 pyrna_srna_ExternalType: failed to find 'bpy_types' module
ModuleNotFoundError: No module named 'bpy_types'
ModuleNotFoundError: No module named 'bpy_types'
ERROR (bpy.rna): c:\users\tgubs\.blenderpy\blender\source\blender\python\intern\bpy_rna.c:6662 pyrna_srna_ExternalType: failed to find 'bpy_types' module
ModuleNotFoundError: No module named 'bpy_types'
ERROR (bpy.rna): c:\users\tgubs\.blenderpy\blender\source\blender\python\intern\bpy_rna.c:6662 pyrna_srna_ExternalType: failed to find 'bpy_types' module
F1106 16:58:18.372622 23956 utilities.cc:322] Check failed: !IsGoogleLoggingInitialized() You called InitGoogleLogging() twice!
*** Check failure stack trace: ***

You need to move the 2.79 folder to the directory containing the python executable.

simply go into your python env, into the Scripts directory, cut the 2.79 folder out of there and paste it into the folder containing the Conda Python executable. The problem is that the version folder ( 2.79 , currently) must be sibling to the Python executable. Since whatever environment you are in does not have the python.exe file located alongside the Scripts ( pip , venv , etc) it is complaining since the path to bpy_types is supposed to be ./2.79/scripts/modules/bpy_types.py (relative to the current python.exe that is trying to import it) and it can't find it.

Windows is a known platform where these script files can be different, especially depending on your environment.

So in short:

Find the folder 2.79 Cut it from the current location Paste it into the folder containing python.exe

Please see this issue

First) check your python version if it's not more than 3.7 and less than <3.8 because bpy module requires Python >=3.7, <3.8 .

Second) check (mostly i guess) C://USER//USER(your user name)//AppData//Programs//Python//Python37//Scripts directory. (just check where your python installed on your local) there should be folder named 2.XX (i guess it's 2.82 but it depends on your bpy version) you should move 2.XX folder to outside of the Scripts folder . (in Python 37 folder)

Then it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM