I have seen this question now many times and every question here and on other forum points to build blender as python module experimental tutorial by ideaman42. Now sadly a lot of answers are invalid right now because this central link is down. I couldn't find anything by Googling so if anybody has a fork of the tutorial or a second source that would be great? The link can't be gone for too long, I saw an answer with it 4 months ago.

The only other thing I have found is this tutorial for windows, but it also references the now missing tutorial. Any ideas how to find it?

  • $\begingroup$ Are looking for all of blender as a python module or just "fake version" to be used for coding in an IDE? $\endgroup$ – Striar Aug 29 '18 at 20:49
  • $\begingroup$ I just want to insert cubes a camera and perform a visibility test. I was thinking of maybe ray casting not sure yet. But yeah not the full blender $\endgroup$ – Hakaishin Aug 29 '18 at 21:01
  • $\begingroup$ The old wiki pages are still available with a slightly altered URL in blenders archived wiki. It really isn't that different to a normal blender build, mostly you need to enable the WITH_PYTHON_MODULE option. $\endgroup$ – sambler Aug 30 '18 at 5:44
  • $\begingroup$ I struggled with following the processes on the (archived) blender wiki, but managed to muddle through eventually with the help of this and a few other StackExchange questions. I've written up the full process I used on GitHub here $\endgroup$ – B.Roullier Feb 21 '19 at 11:30

Here it is pulled from the archive.is (all Ideasman42 cited):


The official blender.org 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 being 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 Blender.org isn't distributing it along with regular releases, Currently, its a build option you can enable, for your own use.


This is a build option to be able to import blender into python and access its modules

Possible uses include:

  • rendering animations.
  • image processing using Blender's compositor.
  • video editing (using Blender's sequencer).
  • importers, exporters (convert 3D file formats).
  • development, accessing bpy from Python IDE's and debugging tools for example. automation.

This is mainly limited to features which can be usable in background mode, so you cant for instance do OpenGL preview renders.



get Python3.6-Framework from Python.org and install it.


Assuming you have a CMake out-of-source build setup, see: http://wiki.blender.org/index.php/Dev:Doc/Building_Blender/Linux/Ubuntu/CMake

Change these CMake options from the defaults:


Everything should build as normal except in the cmake directory you will have ./bin/bpy.so instead of ./bin/blender



  • System Wide Install

    You may want install the module to the systems Python path, eg:


    For a system wide installation:


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

    Once these optiosn are set, run:

    make install
  • Local Install

    Alternately you might want to use your user Python path (see https://www.python.org/dev/peps/pep-0370/)


    For a local install use the following options:


    Once these optiosn are set, run:

    make install


copy bin\bpy.pyd C:\Python36\Lib\site-packages\
copy bin\*.dll C:\Python36\Lib\site-packages\
del C:\Python36\Lib\site-packages\python36.dll
xcopy /E bin\2.79 C:\Python36\


After compiling and "make install", copy needed files to your python framework

cp ./bin/bpy.so 
cp -R ./bin/2.79 

Note. Unlike on *nix C:\Python36\2.79 is not in the site packages, this is because of a difference in how Windows finds the scripts path and should eventually be fixed.


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

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 test.py


The Python version requirements are the same with building a regular blender binary (if Blender us using Python3.6 then there is NO WAY to use another version - 2.7/3.2/3.6 will all fail).

On Windows, you probably won't want to use a debug build, since this requires a debug python installation (python36_d.dll rather then python36.dll), so while it can be made to work, its more trouble.

| improve this answer | |
  • $\begingroup$ Does making such an install interfere if I would already have installed blender normally over apt? My idea is to install blender then test something and if it works to automate it, but I'm not sure if an already existing blender installation over ubuntus package manager would interfere with building it as a python module $\endgroup$ – Hakaishin Aug 31 '18 at 11:45
  • 1
    $\begingroup$ @Hakaishin That shouldn't be a problem, you can install the builded module locally, there shouldn't be any interference $\endgroup$ – Jaroslav Jerryno Novotny Aug 31 '18 at 14:17
  • $\begingroup$ Do you know maybe if another version of python can be used like 3.6 or does it have to be 3.4? I vaguely remember reading somewhere that it will only work with 3.4 but I'm not sure $\endgroup$ – Hakaishin Sep 3 '18 at 8:07
  • $\begingroup$ @Hakaishin It should be the same version as is bundled with Blender, so for 2.79b python 3.5.3. You get the version like this $\endgroup$ – Jaroslav Jerryno Novotny Sep 3 '18 at 8:59
  • 1
    $\begingroup$ @Hakaishin Yes, this you can. You can compile Blender with python 3.6, pass -DPYTHON_VERSION=3.6 when configuring CMake. $\endgroup$ – Jaroslav Jerryno Novotny Sep 3 '18 at 10:40

I struggeld probably the same way as you did but i managed to actually build it as a Python module in the End.

I'm on a Ubuntu 18.04 LTS System so the following report on how i achieved it might depend on the system.

Now to the process of the solution.

Starting point were the following three sources as follows :

  1. Your Question here

  2. An Archived Blender Wiki entry

  3. The offical "Build from source" Wiki article

How did i achieve the build ?

I started by following the description provided of the 2. Source; which wasn't really precise in how to handle the source and so on and did not work for me in the end.

After a few failures of this, i went on by just following the 3. Source.

So i did what was stated there :

mkdir ~/blender-git
cd ~/blender-git
git clone https://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

Afterwards :

cd ~/blender-git

Now I had every bit of blender code and all dependencies installed. Since i did not want blender compiled with UI (as normal programm) i was curious what (described in the next step, step 3, in Source 3.) make in ~/blender-git/blender offered. So i proceeded with simply calling make help which gave the following (truncated for brevity) output :

Convenience targets provided for building blender, (multiple at once can be used)
* debug     - build a debug binary
* full      - enable all supported dependencies & options
* lite      - disable non essential features for a smaller binary and faster build
* headless  - build without an interface (renderfarm or server automation)
* cycles    - build Cycles standalone only, without Blender
* bpy       - build as a python module which can be loaded from python directly
* deps      - build library dependencies (intended only for platform maintainers)

* config    - run cmake configuration tool to set build options

Note, passing the argument 'BUILD_DIR=path' when calling make will override the
default build dir.
Note, passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments.

"Oh Hey, look what we got!" There it was, a make bpy which promised to solve all my problems.

So i executed it and it compiled. But I ended up with the Python module in a, at least for my desires, wrong directory : /usr/local/PYTHON_SITE_PACKAGES-NOTFOUND. I wondered how this happend.

I soon figured out that I had to reconfigure cmake in the new created ~/blender-git/linux_build_bpy via ccmake linux_build_bpy while in ~/blender-git. There i needed to enable the Advanced Settings via pressing t and then editing the Key PYTHON_SITE_PACKAGES from PYTHON_SITE_PACKAGES-NOTFOUND to my desired Path /usr/lib/python3.6/site-packages.

After changing this i had to rebuild the project, which didn't actually rebuild since the changed setting didn't affect the main build process.

Rebuild in ~/blender-git/blender via make bpy.

In the End I also deleted the stuff in /usr/local/PYTHON_SITE_PACKAGES-NOTFOUND. (Ofc i could've just moved/copied it...)

That's how it worked form me. I hope this is helpful in any kind for anyone in the future.


  1. make bpy might need superuser-rights so do a sudo make bpy and don't worry about a complete rebuild (it's allready done just linking/copying in the end needs those rights).

  2. The configuration after the first build might not be needed or can be done before hand, but i didn't figure out how to do so.

  3. If followed through these steps, and the Python module (strangely a directory called 2.80 or simmilar number) exists in the desired path but yet you are not able to import the module bpy in any of your scripts, make sure that your desired path is included in your PYTHONPATH Env-variable.

| improve this answer | |
  • $\begingroup$ I used make bpy as well but I specified the environment variable PYTHON_ROOT_DIR and let it point to the right python environment in anaconda (here called bpy as well): PYTHON_ROOT_DIR="~/miniconda3/envs/bpy" make bpy. This way, I have blender installed in the right folder directly. $\endgroup$ – Jan Jun 30 '19 at 7:47

If you have anaconda, it is quite simple to build a blender-python package, which will allow you to import bpy in a Python script. The following (slightly modified) instructions were obtained from (https://launchpad.net/blender-conda).

If you want to build from source, execute the following commands:

git clone https://git.launchpad.net/blender-conda
cd blender-conda
conda-build .
conda install python-blender --use-local

If you want to download prebuilt packages, use

conda install -c kitsune.one python-blender

Note that I have no relation to kitsune.one and cannot verify the integrity of the prebuilt packages.

| improve this answer | |

If all you want is a "fake" version of blender's libraries so you can code bpy in an IDE with autocomplete, I'm currently using THIS open source library. It takes a running version of blender and strips out all of the data types and available functions.

Once downloaded it can be run with the following bash script with the paths changed to what they are on your local machine.

"PATH_TO_BLENDER\Blender.exe" -b -P "PATH_TO_PYTHONFILE\pypredef_gen.py"

The generated python files can be brought into your IDE and whereas they provide no functionality (The final script needs to be run in blender) you can code within your IDE of choice with autocomplete.

| improve this answer | |
  • $\begingroup$ Good answer, but this is not my usecase I need to run the code outside of blender $\endgroup$ – Hakaishin Aug 29 '18 at 21:16
  • $\begingroup$ Ah sorry. I miss-understood from the comments earlier. $\endgroup$ – Striar Aug 29 '18 at 21:19
  • $\begingroup$ No problem, maybe somebody else wants to do exactly this $\endgroup$ – Hakaishin Aug 29 '18 at 21:20

As of 2.80 release there is a convenience make target. As following this instruction, run make bpy in place of make full to automatically setup build parameters and compile Blender as a Python module.

| improve this answer | |

There's no need to build full Blender to figure out it's target Python version. There's plenty places in Blender sources that point out to the supported Python version. For example, in CMakeLists.txt:

    message(FATAL_ERROR "At least Python 3.7 is required to build")

As was already pointed out you can simply run make bpy to build Blender as a Python module. This command will automatically set all required variables, no need to worry about it. What is not set is PYTHON_SITE_PACKAGES which can be set after make bpy was called for the first time.

By the way, it's important to follow the instructions and to have the directory structure exactly as described in the official docs:


(see the doc for more detail)

After calling make bpy another folder, with all the needed scripts and binaries will be generated alongside those other 2 folders. In my case, on Ubuntu it's:

your_blender_dev_dir/build_linux_bpy    - your new, generated folder.

During the first generation I also caught an exception in the very end of the process(related to PYTHON_SITE_PACKAGES variable):

now run: "make install" to copy runtime files and scripts to PYTHON_SITE_PACKAGES-NOTFOUND/2.90
[100%] Built target blender
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/lib/python3.7/PYTHON_SITE_PACKAGES-NOTFOUND/2.90/scripts
CMake Error at source/creator/cmake_install.cmake:45 (file):
  file INSTALL cannot make directory
  "/usr/lib/python3.7/PYTHON_SITE_PACKAGES-NOTFOUND/2.90/scripts": No such
  file or directory.
Call Stack (most recent call first):
  cmake_install.cmake:45 (include)

Now, this is where ccmake command comes in handy. It's basically just a frontend for cmake that helps you change its input parameters and other configs. Call it in the manner explained by Chgad, but also make sure you are following the hints at the bottom of ccmake console so that you properly configure[c] and generate[g] the corresponding cmake files. I missed one of the commands and as a result cmake files were not regenerated and cmake took variables from its cache on the next run.

In any case, if you managed to set PYTHON_SITE_PACKAGES correctly to where you want it to be(I would recommend system-wide installation because copying all those files into all you virtual envs is a serious burden), you just run make bpy one more time and you are good to go.

Test it with something like:

>>>import bpy
>>>bpy.context.scene.render.engine = 'CYCLES'

Important note: CYCLES renderer is the only working option to run bpy for now, at least on Ubuntu. See here.

| improve this answer | |

may be you can try:

pip install fake-bpy-module-<version>
#Then you can
import bpy

fake bpy github link

| improve this answer | |

I had a lot of troubles with installing bpy, until I figured out that you have to set CMAKE_INSTALL_PREFIX to /usr/lib/python3.7 and not to site-packages. Also in virtual environments, take the root folder of the venv and not site-packages.

| improve this answer | |
  • $\begingroup$ Can you be more specific with the steps you've made? I'm not very familiar with make/cmake and not sure I'm passing BUILD_CMAKE_ARGS/CMAKE_INSTALL_PREFIX correctly. $\endgroup$ – yuranos May 16 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.