Start ipython running a script

In recent versions of ipython you do need to add the -i option to get into the interactive environment afterwards. Without the -i it just runs the code in myfile.py and returns to the prompt.

$ ipython -i myfile.py

Per the docs, it's trivial:

You start IPython with the command:

$ ipython [options] files

If invoked with no options, it executes all the files listed in sequence and drops you into the interpreter while still acknowledging any options you may have set in your ipythonrc file. This behavior is different from standard Python, which when called as python -i will only execute one file and ignore your configuration setup.

So, just use ipython myfile.py... and there you are!-)


Nowadays, you can use the startup folder of ipython, which is located in your home directory (C:\users\[username]\.ipython on Windows). Go into the default profile and you'll see a startup folder with a README file. Just put any Python scripts in there, or if you want ipython commands, put them in a file with an .ipy extension.

Tags:

Python

Ipython