IPython notebook in zc.buildout not using eggs path

泄露秘密 提交于 2019-12-07 13:45:28

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.

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