Skip to content

Instantly share code, notes, and snippets.

@jcayzac
Last active April 14, 2024 06:54
Show Gist options
  • Save jcayzac/2cc076d55cf31819de32e2b7f8d81cdf to your computer and use it in GitHub Desktop.
Save jcayzac/2cc076d55cf31819de32e2b7f8d81cdf to your computer and use it in GitHub Desktop.
How to replace Blender's builtin CPython with a Miniconda-managed python

Using Blender with Miniconda

If you want to play with Blender scripting but the Python packages it ships with aren't enough, you can replace its built-in Python with your own. Here I give you some instructions to swap in a miniconda-managed environment.

These instructions apply for macOS. YMMV.

1. Install Blender

# If you don't like Homebrew you can just get it from https://www.blender.org/download/
brew install blender

# Blender isn't signed
xattr -drv com.apple.quarantine /Applications/Blender.app

2. Install Miniconda

# If you don't like Homebrew you can just get it from https://docs.conda.io/en/latest/miniconda.html
brew install miniconda
conda init

3. Create environment

ls /Applications/Blender.app/Contents/Resources/2.*/python/lib
# Note the version of Python in there, e.g. "python3.9"

# Make sure to use the same version here
conda create --name blender python=3.9

4. Replace Blender's python

cd /Applications/Blender.app/Contents/Resources/2.*

# Archive the original (you may want to restore it)
mv python python.original

# Link to your conda environment
ln -s /usr/local/Caskroom/miniconda/base/envs/blender python

5. Install packages as needed

conda activate blender

# Install things with pip or conda, for example:
conda install scikit-learn
pip install requests
pip install pymesh
pip install --upgrade pip wheel future-fstrings

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