Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yearofthewhopper/4b449e47f5df7e2e1fbf83ee0187a02c to your computer and use it in GitHub Desktop.
Save yearofthewhopper/4b449e47f5df7e2e1fbf83ee0187a02c to your computer and use it in GitHub Desktop.
Blender python api installation on macOS

Instructions are from
https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule Tested with Blender 2.93 on macOS 10.15.7

  1. Install xcode command line
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
  1. Install python 3.7
    https://www.python.org/ftp/python/3.7.9/python-3.7.9-macosx10.9.pkg

  2. Download blender build

mkdir ~/blender-git
cd ~/blender-git
git clone https://git.blender.org/blender.git
cd blender
make update
  1. Build blender python api Using the following solution
    https://devtalk.blender.org/t/undefined-symbols-when-building-blender-as-python-module/7304/9 Change "WITH_OPENM" to OFF in CMakeLists.txt
make
cd ../build_darwin
make install
  1. build bpy
cd ~/blender-git/blender
make
cd ../build_darwin_bpy
make install
  1. Post make
cp ./bin/bpy.so /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/
mkdir -p /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/Resources
cp -R ./bin/2.93 /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/Resources/
  1. Test
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m -c "import bpy; bpy.ops.render.render(write_still=True)"

Blender executable

~/blender-git/build_darwin/bin/Blender.app/Contents/MacOS/Blender

# Test
 ~/blender-git/build_darwin/bin/Blender.app/Contents/MacOS/Blender --background --python test.py
 
 # Install packages
~/blender-git/build_darwin/bin/Blender.app/Contents/Resources/2.93/python/bin/python3.7m -m pip install joblib

Blender python

~/blender-git/build_darwin/bin/Blender.app/Contents/Resources/2.93/python/bin/python3.7m
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment