Nyxynyx Nyxynyx - 2 months ago 56
Python Question

Error starting iPython on Mac OSX: No module named jinja2

iPython
was installed on a Mac OS X Mountain Lion using
pip
. When running
ipython notebook
in the Terminal, I get the error

...
File "/Users/god/.virtualenvs/datasci/lib/python2.7/site-packages/IPython/html/notebookapp.py", line 38, in <module>
from jinja2 import Environment, FileSystemLoader
ImportError: No module named jinja2


Question: What is the problem here, and how should we resolve it?

Answer

Jinja 2 is listed as an optional dependency, see the iPython quickstart.

You must install optional dependencies separately:

pip install Jinja2

You can install such dependencies as optional functionality groups for ipython. Using these let you install the dependencies needed for that functionality; each of these groups can be installed with pip install ipython[groupname]:

So to install all dependencies for ipython notebook use:

pip install ipython[notebook]

and ipython is installed plus the dependencies, or if you already have ipython installed it'll add on the missing packages.

Alternatively, install all optional dependencies with:

pip install ipython[all]