Load iPython with custom packages imported

automation, ipython, python, python-2.7

Solution

What you want is a startup script.

First run `ipython locate profile` to find the profile folder. Then find a `startup` folder in there. Create a .py file (any name) in the startup folder with the imports you want, and IPython will run that whenever you it starts.

Problem

Does anyone know if it is possible to load ipython preloaded with custom packages please? I'm running Python 2.7 on Windows 8. When I load a DOS prompt, I run ipython preloaded with pylab by typing ``` ipython --pylab ``` I've managed to create a shortcut to open a DOS prompt with this automatically fired, thus effectively creating a shortcut to iPython. However, I'd like iPython to start preloaded with some of my custom packages. So I wonder if there is a way to start iPython and automatically execute the following lines, say: ``` import package1 as my_package import package2 as my_second_package ``` I've had a look online and there's some information on "magic" commands and scripts in iPython which looks like it might help, although I wasn't sure how to use this. All guidance welcomed. Many thanks.

Original source