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?
Trial 0: roundaround -solution not working with subprocess inside Blender
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)
Trial 1: not working outside 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
Based on these instructions:
Obtain the blender source code:
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
Take care of the dependencies, see e.g. here if necessary* and compile via the bpy
target:
cd ~/src/blender
make bpy
(re)run the latter as root if errors like file INSTALL cannot set permissions on [...]
occur
Your python 3 should now be able to import bpy
.
* 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