How to fix error when importing the blender module in Python

时光总嘲笑我的痴心妄想 提交于 2019-12-11 17:16:12

问题


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: ***

回答1:


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



来源:https://stackoverflow.com/questions/53167335/how-to-fix-error-when-importing-the-blender-module-in-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!