IPython notebook in zc.buildout not using eggs path

倖福魔咒の 提交于 2019-12-08 07:40:56

问题


I've build an environment with zc.buildout including IPython script.

My problem is simple:

  • if I launch IPython in console, everything is OK and I get all my eggs in sys.path

  • but if I launch IPython notebook, I only get default system path.

Is there any way to include all my eggs while starting notebook?

Regards,

Thierry


回答1:


So, I guess somewhere in the notebook startup a process is forked, which means sys.path will get reset and buildout's tricks won't help.

I solved the problems as follows, although it's a bit dirty:

  1. Create an entry point as follows:

    setup(...
          entry_points = {
              'console_scripts': ['ipython = <yourpackage>.ipython:main']
          })
    
  2. Put the following in /ipython.py:

    from IPython.frontend.terminal.ipapp import launch_new_instance
    import os
    import sys
    
    def main():
        os.environ['PYTHONPATH']=':'.join(sys.path)
        sys.exit(launch_new_instance())
    

Now, running bin/ipython notebook will give you the sys.path you expect.



来源:https://stackoverflow.com/questions/16621896/ipython-notebook-in-zc-buildout-not-using-eggs-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!