In your ipython_config.py file ipython_config.py you can specify the commands to run at startup (including magic% commands) by setting c.InteractiveShellApp.exec_lines . For instance,
c.InteractiveShellApp.exec_lines = """ %matplotlib inline %autoreload 2 import your_favorite_module """.split('\n')
source share