IPython has support for multiple profiles. This is handy if you are working on different projects and want to tweak some behaviors, or test out new settings without changing how IPython will behave globally. By default, IPython will always run the default profile. Once you specify a new profile to create, new configuration files will be created. To create a new profile named zagnut, enter: 2

ipython profile create zagnut
[ProfileCreate] Generating default config file: '/Users/eric/.ipython/profile_zagnut/'

If at some point you forget where this configuration file was created, you can locate it:

ipython locate profile zagnut

To launch IPython with this configuration, pass in the name to the profile argument:

ipython --profile=zagnut
Python 3.9.0 (default, Nov  2 2020, 18:14:37)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.

IPython profile: zagnut

In [1]:

To exit the shell, you can enter exit or use the keyboard shortcut CTRL-D.

If you are a Django developer and want to use an IPython profile in conjunction with the Django shell, you can do it by using the django-extensions package:

pip install django-extensions

It has a shell_plus extension (which gives you some niceties like auto importing your models), and you can pass the profile name in as:

python shell_plus --ipython -- --profile=zagnut

Note that there is a separate double dash (--) before the --profile.

Since this is kind of a long command to type each time you want to pop into a shell, I alias mine to something much simpler to remember: Python manage shell_plus:

alias pms='python shell_plus --ipython -- --profile=zagnut'

2. We all remember the candy bar of choice for Beetlejuice, right? No? Just me?