改变每个IPython笔记本中的路径

时间:2014-11-06 05:01:31

标签: python path ipython

我想更改为IPython配置文件加载的每个笔记本的路径。我在Mac OS X上有以下目录结构:

/Users/user/project
├── main.py
├── reqs
├── notebooks
├── profile
└── ve, requirements.txt...

在此配置文件中,我想向用户显示notebook文件夹中的笔记本,将此根文件夹添加到路径中,并在那里预加载mainreqs模块

我创建了一个profile文件夹,我像这样运行IPython:

$ ./ve/bin/ipython notebook --profile-dir=`pwd`/profile

我将以下内容添加到文件profile/startup/00-setup.py

c = get_config()

import os, sys

# Modify the path to include the core files
cur_folder = os.path.dirname(os.path.realpath(__file__))
sys.path.append('{}/../..'.format(cur_folder))

# Preload some modules
from main import *
from reqs import *

但不知何故,这并没有任何影响,而且在发布时我也没有看到任何错误。

我发现问题Change IPython working directory是相关的,但在我的情况下,我想要添加的路径与notebooks文件夹不同。

由于

0 个答案:

没有答案