zc.buildout中的IPython笔记本不使用egg路径 [英] IPython notebook in zc.buildout not using eggs path
问题描述
我用zc.buildout构建了一个包含IPython脚本的环境。
I've build an environment with zc.buildout including IPython script.
我的问题很简单:
-
如果我在控制台中启动IPython,一切正常,我在sys.path中获取所有鸡蛋
if I launch IPython in console, everything is OK and I get all my eggs in sys.path
但如果我启动IPython笔记本,我只会得到默认系统路径。
but if I launch IPython notebook, I only get default system path.
有没有办法包括我的所有鸡蛋在启动笔记本时?
Is there any way to include all my eggs while starting notebook?
问候,
Thierry
推荐答案
所以,我想在笔记本电脑启动过程中某个进程是分叉的,这意味着sys.path将被重置并且buildout的技巧将无济于事。
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:
-
创建一个入口点如下:
Create an entry point as follows:
setup(...
entry_points = {
'console_scripts': ['ipython = <yourpackage>.ipython:main']
})
将以下内容放在/yython.py中:
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())
现在,运行 bin / ipython notebook
将为您提供您期望的sys.path。
Now, running bin/ipython notebook
will give you the sys.path you expect.
这篇关于zc.buildout中的IPython笔记本不使用egg路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!