简体   繁体   English

在 Python 中导入搅拌机模块时如何修复错误

[英]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'当我将 bpy 导入 python 时出现以下错误代码,这是因为我需要安装搅拌机,或者我可以用另一种方式解决这个问题吗?

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.您需要将2.79文件夹移动到包含 python 可执行文件的目录。

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.只需进入您的 python 环境,进入 Scripts 目录,从那里剪切2.79文件夹并将其粘贴到包含 Conda Python 可执行文件的文件夹中。 The problem is that the version folder ( 2.79 , currently) must be sibling to the Python executable.问题是版本文件夹(当前为2.79 )必须是 Python 可执行文件的兄弟。 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.由于您所处的任何环境都没有位于脚本旁边的python.exe文件( pipvenv等),因此它会抱怨,因为bpy_types的路径应该是./2.79/scripts/modules/bpy_types.py (相对到当前试图导入它的python.exe )并且它找不到它。

Windows is a known platform where these script files can be different, especially depending on your environment. Windows 是一个已知平台,其中这些脚本文件可能会有所不同,尤其是取决于您的环境。

So in short:简而言之:

Find the folder 2.79 Cut it from the current location Paste it into the folder containing python.exe找到文件夹2.79从当前位置剪切 粘贴到包含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 .首先) check your python version是否不超过 3.7 且小于 <3.8 因为 bpy 模块需要Python >=3.7, <3.8

Second) check (mostly i guess) C://USER//USER(your user name)//AppData//Programs//Python//Python37//Scripts directory.第二)检查(主要是我猜)C://USER//USER(你的用户名)//AppData//Programs//Python//Python37//Scripts 目录。 (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 . (只需检查您的 python 安装在本地的位置)应该有一个名为2.XX的文件夹(我猜它是 2.82,但这取决于您的 bpy 版本)您应该move 2.XX folder to outside of the Scripts folder (in Python 37 folder) (在 Python 37 文件夹中)

Then it should work.然后它应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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