Skip to content

Building Blender as a Python Module


The official embeds a Python interpreter (CPython 3.x). This makes sense from the perspective of a user, who's primary needs are to have an application which can be extended with scripts.

However from the perspective of a Python developer, it can be useful to bring Blender into your existing scripts and access its feature set.

The option to build Blender as a Python module is not officially supported, in the sense isn't distributing it along with regular releases. Currently, its a build option you can enable, for your own use.

For details on API usage see: see Python Reference Manual Page.


Quick Setup

See building blender docs for instructions, but run make bpy instead of make.

After building succeeds, there should be a bin/bpy/ folder with the module. See the next section for how to install this.

Manual CMake Setup

Instructions are the same as manual CMake setup for regular builds, but changing the cmake command to include the configuration for the Python module.

cmake -C ../blender/build_files/cmake/config/bpy_module.cmake ../blender

See build_files/cmake/config/bpy_module.cmake for details about which options are different than a regular Blender build.


Python Wheel

Blender provides a utility to create a *.whl (wheel) file, which can then be installed.

To create a wheel file, run the following command:

python3 ./build_files/utils/ ../build_{platform}_bpy/bin/

Where the first argument is the directory containing the "bpy" directory.

The wheel can be installed with pip, e.g:

pip3 install bpy-{version-and-platform}.whl


System Wide Install

You may want to copy into the module to the systems Python path, e.g.:


For a system wide installation:



PYTHON_SITE_PACKAGES will be used as the target path, but this is auto detected, nevertheless, you may want to modify.

Once these options are set, from the BPY build directory (build_linux_bpy/ by default) run:

make install

Local Install

Alternately you might want to use your user Python path (see


For a local install use the following options:


Once these options are set, from the BPY build directory (build_linux_bpy/ by default) run:

make install


Copy the bpy directory into Python's site-packages:

xcopy /E bin\bpy C:\Python311\Lib\site-packages\bpy


Local Install

mkdir -p $HOME/.local/lib/python3.11/site-packages/
cp -r ./bin/bpy $HOME/.local/lib/python3.11/site-packages/

System Wide Install

For a Python installation from

cp -r ./bin/bpy /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/


This allows 'bpy' to be imported from Python or other applications/IDE's which embed python, eg:

python -c "import bpy, os; bpy.ops.wm.save_as_mainfile(filepath=os.path.abspath('my.blend'))"

On Linux, using the GPU to render is supported (for EEVEE rendering):

python -c "import bpy; bpy.ops.render.render(write_still=True)"

This runs in background mode and has similar restrictions to running a script:

blender --background --python

If the build folder is still there, ctest -VV -C config (where config is Debug or Release etc.) can be run in the build folder to see if bpy has been installed properly. CTest docs.


  • The Python version requirements are the same with building a regular blender binary (if Blender is using Python3.11 then there is NO WAY to use another version - 2.7..3.9/3.10 will all fail).
  • On Windows, you probably won't want to use a debug build, since this requires a debug python installation (python311_d.dll rather then python311.dll), so while it can be made to work, its more trouble.