Ipython: Set default IPython profile with environment variable

Created on 21 Aug 2019  ·  3Comments  ·  Source: ipython/ipython

It would be nice to set the IPython profile with an environment variable, i.e. something like

$ IPYTHON_PROFILE=testing ipython
Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.7.0 -- An enhanced Interactive Python. Type '?' for help.

IPython profile: testing
In [1]:

My particular use case is to use the conda {de,}activate.d/ hooks to change profiles based on which conda environment is active. At the moment, an easy hack is to alias ipython to ipython --profile={profile} and then unalias in deactivate, but environment variables would be cleaner.

Most helpful comment

:+1:
It would be nice to have this feature. Many applications let use IPython instead of standard shell, but we cannot specify profile when it invokes.

All 3 comments

$IPYTHONDIR allows you to redefine $HOME/.ipython (where the profiles are located) to somewhere else, rather than which profile is selected.

You could have a hack where each profile sits in its own .ipython directory, but this is worse than the alias trick.

:+1:
It would be nice to have this feature. Many applications let use IPython instead of standard shell, but we cannot specify profile when it invokes.

Was this page helpful?
0 / 5 - 0 ratings