I want to lunch my iPython notebook kernel remotely and have it import a setup.py file automatically at startup. I have tried
python notebook --no-browser
one of the output message is:
Using existing profile dir: u'/path/to/profile_default'
such directory contains a startup folder which contains my setup.py file.
Unfortunately the content of the file is not imported as expected.
I am looking for the notebook equivalent of the -c option for the standard shell.
In case is relevant, this is still on Python 2.7.
1 Answer 1
Create a new ipython profile,
$ ipython profile create foo
Edit the ipython_config.py file it generates, you can locate it with:
$ ipython locate profile foo
After
c = get_confg()
Add
c.InteractiveShellApp.exec_lines = ['import setup']
Then start the notebook with the --profile argument,
$ ipython notebook --no-browser --profile=foo
If you don't want to create a profile, then you can add this via command-line by using --ClassName.attribute=...
$ ipython notebook --no-browser --InteractiveShellApp.exec_lines="['import setup']"
More information on ipython profiles: http://ipython.org/ipython-doc/stable/config/intro.html
4 Comments
--ClassName.attribute=.... I have updated my answer to give an example.