0

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

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

Sign up to request clarification or add additional context in comments.

4 Comments

That's interesting, but since I need to create a make file to start this process up, I am trying to minimize the amount of manual work. Is there a way to pass the code directly via command line at start up time?
If you're wanting to distribute this, then you can distribute the profile alongside your Makefile.
So I guess is not possible to pass arbitrary code via the command line?
@meto Turns out you can pass in any configuration option through the command-line by using --ClassName.attribute=.... I have updated my answer to give an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.