Domanda

I use zc.buildout to build my python application environment. I want to run IPython notebook and use my custom packages to further test and develop.

[buildout]
extends = buildout.cfg

parts += 
    ipython_part

[versions]
ipython = 0.13.2
pyzmq = 13.0.2


[ipython_part]
#http://ipython.org/ipython-doc/stable/install/install.html#dependencies-for-the-ipython-html-notebook
#https://github.com/bearstech/ipython_notebook/blob/master/buildout.cfg
recipe = zc.recipe.egg
dependent-scripts = true
eggs = 
       ipython[zmq,notebook,test]
       ${myapplication:eggs}

Starting the notebook works, but as soon as I create a new notebook the Kernel dies.

[NotebookApp] Kernel started: c7c64caf-c966-4863-b37d-11cf11901882
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named IPython.zmq.ipkernel

Running IPython inside a virtualenv works like a charm. My problem is related to a buildout setup. I am aware of this answer. It works.

Regarding the wide spread use of buildout & IPython notebook this must be a common situation. Are there any buildout recipes to make it work out-of-the-box?

È stato utile?

Soluzione

According to this answer in the notebook startup a process is forked and looses the sys.path prepared by buildout. The same solution should apply to your case as well.

Edit: I settled on adding an initialization keyword to my "development" recipe:

[development]
recipe = zc.recipe.egg
eggs = ipython[all]
# ugly work-around needed for ipython nootbook
initialization =
    import sys, os
    os.environ['PYTHONPATH'] = ':'.join(sys.path)

Much more clean and it mostly work.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top