Mac OSX Yosemite上的iPython笔记本:没有名为jinja2的模块,即使它已安装

时间:2015-01-08 15:41:42

标签: jinja2 ipython-notebook osx-yosemite

我正在尝试在OSX Yosemite上运行iPython笔记本。我已经通过

安装了所有内容
pip install ipython[all]

我看到了

mattia:~ mattiaspeziali$ pip freeze
backports.ssl-match-hostname==3.4.0.2
certifi==14.5.14
docutils==0.12
gnureadline==6.3.3
ipython==2.3.1
Jinja2==2.7.3
MarkupSafe==0.23
nose==1.3.4
numpy==1.8.2
numpydoc==0.5
pandas==0.14.1
Pygments==2.0.1
pyzmq==14.4.1
Sphinx==1.2.3
tornado==4.0.2
vboxapi==1.0

然而,jinja2似乎安装不正确:

    mattia:~ mattiaspeziali$ ipython notebook
Traceback (most recent call last):
  File "/usr/local/bin/ipython", line 11, in <module>
    sys.exit(start_ipython())
  File "/Library/Python/2.7/site-packages/IPython/__init__.py", line 120, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 563, in launch_instance
    app.initialize(argv)
  File "<string>", line 2, in initialize
  File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/IPython/terminal/ipapp.py", line 321, in initialize
    super(TerminalIPythonApp, self).initialize(argv)
  File "<string>", line 2, in initialize
  File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/IPython/core/application.py", line 381, in initialize
    self.parse_command_line(argv)
  File "/Library/Python/2.7/site-packages/IPython/terminal/ipapp.py", line 316, in parse_command_line
    return super(TerminalIPythonApp, self).parse_command_line(argv)
  File "<string>", line 2, in parse_command_line
  File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 475, in parse_command_line
    return self.initialize_subcommand(subc, subargv)
  File "<string>", line 2, in initialize_subcommand
  File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 92, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/IPython/config/application.py", line 406, in initialize_subcommand
    subapp = import_item(subapp)
  File "/Library/Python/2.7/site-packages/IPython/utils/importstring.py", line 42, in import_item
    module = __import__(package, fromlist=[obj])
  File "/Library/Python/2.7/site-packages/IPython/html/notebookapp.py", line 42, in <module>
    from jinja2 import Environment, FileSystemLoader
ImportError: No module named jinja2

我还尝试卸载并重新安装jinja2,但没有任何改变。有什么建议吗?

另外:

mattia:~ mattiaspeziali$ which python /usr/local/bin/python

mattia:~ mattiaspeziali$ which ipython /usr/local/bin/ipython

mattia:~ mattiaspeziali$ which pip /usr/local/bin/pip

2 个答案:

答案 0 :(得分:1)

重新安装iPython解决了这个问题。

答案 1 :(得分:0)

我遇到了与jinja2 + ipython [笔记本]同样的问题。似乎jinja2不是强制运行ipython终端并且默认情况下不安装它。

但是你必须在ipython之前安装它才能打开笔记本。