本文介绍了如何在标准python控制台中访问BPY? BPY是Blender-python -thing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作者此处在第17.20-17.50点中提到,将来您可以使用标准Python解释器访问BPY.已经1岁了,如何使用标准python控制台访问BPY?

The author here in point 17.20-17.50 mentions that you can access BPY with the standard Python interpreter in the future. It is already 1 year old so how can I access the BPY with the standard python console?

subprocess.call(['vim', 'test.py'])
# some editing of BPY -file with Vim (not working currently)
subprocess.call(['python', 'test.py'])  
# trying to execute the python -file (not working currently)

试验1:无法在Blender外部工作

$ cat cubes.py 
import bpy

mylayers = [False]*20
mylayers[0] = True
add_cube = bpy.ops.mesh.primitive_cube_add
for index in range(0, 5):
    add_cube(location=(index*3, 0, 0), layers=mylayers)
$ python cubes.py 
Traceback (most recent call last):
  File "cubes.py", line 1, in <module>
    import bpy
ImportError: No module named bpy

推荐答案

基于这些说明:

获取搅拌机源代码:

cd ~/src # or what you prefer
git clone http://git.blender.org/blender.git

cd blender
git submodule update --init --recursive
git submodule foreach git checkout master
git submodule foreach git pull --rebase origin master

请注意相关性,例如此处(如有必要)并通过bpy目标进行编译:

Take care of the dependencies, see e.g. here if necessary and compile via the bpy target:

cd ~/src/blender
make bpy

如果出现类似file INSTALL cannot set permissions on [...]的错误,请重新以root用户身份运行

(re)run the latter as root if errors like file INSTALL cannot set permissions on [...] occur

您的python 3 现在应该能够import bpy.

Your python 3 should now be able to import bpy.

对于运行Debian的系统

For Debian-ish systems run

sudo apt-get install subversion build-essential gettext \
 libxi-dev libsndfile1-dev \
 libpng12-dev libjpeg-dev libfftw3-dev \
 libopenexr-dev libopenjpeg-dev \
 libopenal-dev libalut-dev libvorbis-dev \
 libglu1-mesa-dev libsdl1.2-dev libfreetype6-dev \
 libtiff4-dev libavdevice-dev \
 libavformat-dev libavutil-dev libavcodec-dev libjack-dev \
 libswscale-dev libx264-dev libmp3lame-dev python3.2-dev \
 libspnav-dev libtheora-dev libjack-dev libglew1.6-dev

这篇关于如何在标准python控制台中访问BPY? BPY是Blender-python -thing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 06:10