Getting DEAP (or any python module) into Blender

In my quest to make lots of different interesting shapes, I am attempting to use DEAP inside of blender. Deap stands for Distributed Evolutionary Algorithms in Python. Deap has a module for implementing genetic programming, which I am curious and excited to use as a way of automatically generating growth rules.  Genetic programming evolves computer programs to perform some sort of task well. I am not really sure, at the moment, if it is important that the growing tree-structures perform some task well. However, the deap package includes an interface for easily generating random programs from a collection of predefined 'primitves' or basic functions. It also allows one to easily construct a genetic algorithm which uses the randomly generated programs as 'genomes.'  Anyway, first I need to make the deap package available within blender!

1. Blender's most current versions use python 3. Deap is written in python 2. So to covert I used the command 2to3 as follows (note I am on OSX):

$ 2to3 --output-dir=/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/deap -W -n /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/deap

2. The next step is to get blender's version of python to be aware of deap. The quickest way I found to do this is to add the location of the python 3.5 site-packeges to blender's path. This is done according to this thread. In blender's console I did this:

>>> sys.path.append('/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/
>>> import

It works! Of course this a bit of a hacky way of getting deap (or any third-party python module) into blender. More permanent ways of making the module available for import are described here.

Written on December 7, 2016