Skip to content

Instantly share code, notes, and snippets.

@alexlee-gk
Last active January 12, 2022 15:34
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save alexlee-gk/3790bf5916649082d9d6 to your computer and use it in GitHub Desktop.
Save alexlee-gk/3790bf5916649082d9d6 to your computer and use it in GitHub Desktop.
Install blender as a module with python 3.5 and pyenv

#Install blender as a module with python 3.5 and pyenv

Tested on Ubuntu 14.04.

Setting up a new python environment using pyenv

Follow instructions from here.

Installing boost

Follow instructions from here.

Installing blender as a module

The instructions are mostly the same as the official installation instructions except for a few modifications specified below.

Install the python dependecies using pip:

pip install numpy
pip install requests

When blender is build as a module, the blender binary doesn't get built. So, first build blender as normal following these instructions. Run install_deps.sh to generate the cmake options. For example, build all libraries except for opensubdivision, opencollada and ffmpeg:

./blender/build_files/build_environment/install_deps.sh --source ./ --threads=4 --with-all --skip-osd --skip-ffmpeg

When using cmake, use the following python options (in addition to any other options returned from the command above that you need):

cmake -DPYTHON_VERSION=3.5 -DPYTHON_ROOT_DIR=~/.pyenv/versions/3.5.1 ../blender

Make sure to build it and install it:

make -j4
make install

This should have created the blender binary bin/blender. Now, build blender as a module as described in the original post (in addition to any other options):

cmake -DWITH_PLAYER=OFF -DWITH_PYTHON_INSTALL=OFF -DWITH_PYTHON_MODULE=ON ../blender

Build it an install it:

make -j4
make install

This should have created the python library bin/bpy.so.

@nfehrenbach
Copy link

@davidwessman I am stuck on the same step you were in Feb 20, except the official instructions have been taken down. Do you recall how to point to your site-packages? Trying to copy just bpy.so into my pyenv's site packages for the python distribution I used (anaconda3-5.2.0) I am able to import bpy, but immediately have errors thrown because it can't find any of the other dependencies.
Thanks!

@danong
Copy link

danong commented Aug 9, 2018

@nfehrenbach I don't know the answer to your exact problem but you can still access the instructions at the old wiki: https://en.blender.org/index.php/User:Ideasman42/BlenderAsPyModule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment