# Install Python module for Blender

I'd like to install some python modules which need to be compiled and use them in Blender. Usually I'd pip install them but that doesn't seem to be a possibility for Blender. I tried copying sys.path from my system python environment but it came up with quite a few errors.

The modules are cython and mdtraj - both are available using anaconda and pip but both need to be compiled for the python environment they're supposed to be run on.

So how should I go about installing/setting those up for use in Blender?

• – p2or Nov 9 '15 at 11:52

You need modules that work with the same Python version as the one shipped with blender (currently, blender 2.78 is shipped with Python 3.6.0).

My favorite Python distribution is anaconda. Here are the steps I just followed for blender 2.78 in linux (a similar setup should be easy to get for windows or macos).

1. Install anaconda.
2. Create an specific environment for the modules you need in blender:
conda create --name conda-python-blender python=3.6.0

1. Activate this environment:
source activate conda-python-blender

1. Install all your required libraries ("modules"):
conda install cython

1. You can also use pip if your library is not (yet) in anaconda repositories:
pip install mdtraj

1. Figure out the directory where your libraries are stored:
echo "import sys; print(sys.path)" | python


In my case, I get:

['', '/home/christophe/anaconda3/envs/conda-python-blender/lib/python36.zip', '/home/christophe/anaconda3/envs/conda-python-blender/lib/python3.6', '/home/christophe/anaconda3/envs/conda-python-blender/lib/python3.6/lib-dynload', '/home/christophe/anaconda3/envs/conda-python-blender/lib/python3.6/site-packages', '/home/christophe/anaconda3/envs/conda-python-blender/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg']


You want the "site-packages" directory, so, in my case:

/home/christophe/anaconda3/envs/conda-python-blender/lib/python3.6/site-packages

1. Open blender, then go to the Python console and do the following as Rich Colburn said, that is adding the previous directory the the path where Python is looking for libraries:
  import sys
sys.path.append('/home/christophe/anaconda3/envs/conda-python-blender/lib/python3.6/site-packages')


And that's it!

1. Optional step. If you want to make it permanent so that every time you open a new blender file, blender adds automatically the required directory to the path, then save the following lines in a file (say add-anaconda-libs-to-path.py) and put the file in ./scripts/startup/ (for me it is /home/christophe/.config/blender/2.78/scripts/startup/.
import sys
sys.path.append('/home/christophe/anaconda3/envs/conda-python-blender/lib/python3.6/site-packages')
def register():


A final note: unless you want to update your libraries with conda, you don't have to activate the conda-python-blender environment anymore as blender will use its own Python interpreter.

I was able to get scipy to load just now by doing this:

import sys
sys.path.append('C:\\Users\\me\\AppData\\Local\\Continuum\\Anaconda3\\Lib\\site-packages')
import scipy


The site-packages is the folder containing the scipy folder

• This works quite well provided conda python version is the same as python shipped with blender. For blender 2.78, be sure to install python 3.6.0 with conda. – cjorssen Mar 21 '17 at 15:52