29

It is possible to make persistent changes to settings for default settings on Windows 7? I would like to change font-size and shell size.

minrk
  • 37,545
  • 9
  • 92
  • 87
John
  • 41,131
  • 31
  • 82
  • 106

7 Answers7

28

Instructions on configuring the ipython command line application are here on IPython's web site. Step-by-step instructions for configuring the font size in particular:

First, create the IPython profile. Simply running IPython or IPython's QtConsole should do this for you, but if you have to do it by hand, run

ipython profile create

Second, create an IPython config file:

  • Windows - %USERPROFILE%\.ipython\profile_default\ipython_config.py
  • Linux or OS X - ~/.ipython/profile_default/ipython_config.py

Sample IPython contents:

c = get_config()

c.IPythonWidget.font_size = 11
c.IPythonWidget.font_family = 'Consolas'

There's a more detailed sample config file at ipython.org.

Josh Kelley
  • 56,064
  • 19
  • 146
  • 246
  • 1
    That last link is now broken, I think http://ipython.org/ipython-doc/stable/config/index.html is the updated equivalent. – schodge Mar 16 '14 at 23:05
  • @schodge - Updated. Thanks! (In the future, feel free to propose an edit yourself, instead of just adding a comment.) – Josh Kelley Mar 17 '14 at 02:36
  • @JoshKelley `ipython profile create` shows syntax error. – Avinash Raj Feb 05 '15 at 08:12
  • @AvinashRaj - Works for me, so I don't know what's wrong. If you're still having problems, a separate question, with more detail, would be easier than discussing via comments. – Josh Kelley Feb 05 '15 at 13:37
  • schodge's updated link works. Also, for the intro guide: https://ipython.org/ipython-doc/stable/config/intro.html – Jacob Irwin Dec 13 '15 at 04:31
  • 1
    If you want to change the size of initial window, use `c.IPythonWidget.height = 36`, `c.IPythonWidget.width = 96` (value refers to the number of rows or columns). – oracleyue Jun 23 '16 at 16:00
  • Your post describes how to configure IPython. The OP wants to know how to configure the jupyter qtconsole. When I make changes to my ipython_config.py file, they are not recognized by the console opened with `%qtconsole` in jupyter. What am I missing here? Thanks! – timgeb Jan 28 '20 at 13:08
5

The QtConsole has configurable via the ConsoleWidget. Start with:

> ipython qtconsole --ConsoleWidget.font_size=11
2

With the most recent versions of IPython/Jupyter:

  1. The relevant config file is now ~/.jupyter/jupyter_qtconsole_config.py

    At the top of the file we do c = get_config()

  2. The relevant command for font size is c.ConsoleWidget.font_size = 12

  3. (See: a reference for the other configurable options.)

  4. Another setting is c.JupyterWidget.syntax_style = "trac" (for example), which is a colour-scheme setting. List of schemes. It is possible to create a custom scheme: the easiest way seems to be to put a your_name_here.py into the $PYTHON/Lib/site-packages/pygments/styles directory, of a similar format to the other files there. (Configuring things this way sounds a bit fragile, but the other suggested way, of registering the custom scheme, seems similarly fragile.) More styles may be specified using CSS. In the config file as above:

    c.JupyterQtConsoleApp.stylesheet = '/path/to/your_name_here.css'
    

    An example "LightBG" stylesheet is given here. (There are only a few CSS classes. Some of the default highlighting still stays as default, with no way to change them using either the CSS or the Pygments style file. For example, the highlighting of a SyntaxError message stays at the default. This might have been fixed in the most recent version — see the discussion here.)


Here's a bonus. A shortcut for changing IPython qtconsole settings using one function call.

Put the following code into a file named IPYTHON_PROFILE_DIR/startup/startup.ipy. (For some reason this is still under ~/.ipython, not ~/.jupyter.) It can be named something other than "startup.ipy", but the extension must be .ipy, not .py.

def edit_config():
    profile_path = !ipython locate profile
    !{'gvim "%s/ipython_config.py"' % profile_path[0]}

(Replace "gvim" with your preferred editor.)

Now, whenever you need to tweak your Jupyter Qtconsole configuration, you'll be able to bring it up using:

In [1]: edit_config()
Evgeni Sergeev
  • 22,495
  • 17
  • 107
  • 124
  • The actual line I use is: `!{'gvim -p "{0}/ipython_config.py" "{0}/../../.jupyter/jupyter_qtconsole_config.py" '.format(profile_path[0])}` This is to open both config files in tabs. – Evgeni Sergeev Sep 08 '16 at 12:06
  • When launching "qtconsole" with the the most recent version of Anaconda Navigator, the `c = get_config()` seems to "hang" launching of the console. Removing that and just using the variable `c` as above works just fine. – Dave C Nov 27 '17 at 15:21
1

Step by step, one would do like this:

In bash under Windows 7 (MingW), I would get help straight from IPython with

/c/Python27/Scripts/IPython.exe qtconsole --help-all | grep font2.

Then you just have to edit ipython_config.py (which is located in your .ipython home directory. In Windows 7: /c/Users/< your_user >/.ipython/profile_default/ipython_config.py

c.IPythonWidget.font_size = 11
c.IPythonWidget.font_family = 'Calibri'

For the window size, look at this issue. You may need to install a recent version.

dmvianna
  • 15,088
  • 18
  • 77
  • 106
1

you can right click on the ipython windows and select "Default". you can set your default configuration from there.

1

Works for linux:

Use https://bitbucket.org/joon/color-schemes-for-ipython-qt-console

pip install jupyter_qtconsole_colorschemes

In ~/.jupyter/jupyter_qtconsole_config.py, you can further configure other settings mentioned here(https://jupyter.org/qtconsole/stable/config_options.html):

Example:

color_theme = 'monokai'  # specify color theme

import pkg_resources
c.JupyterQtConsoleApp.stylesheet = pkg_resources.resource_filename(
    "jupyter_qtconsole_colorschemes", "{}.css".format(color_theme))

c.JupyterWidget.syntax_style = color_theme
c.ConsoleWidget.font_size=15
Abhishek Bhatia
  • 9,404
  • 26
  • 87
  • 142