user1968963
user1968963

Reputation: 2521

syntax highlighting in ipython console

I am using ipython both in qtconsole and in the terminal

In ipython-qtconsole, when I type import pandas as pd the words have syntax highlighting.

However, when I type in the console, all text is white.

Is it possible to have syntax highlighting in Python console as well?

My ipython versions are:

ipython                    1.2.1
ipython-qtconsole          1.2.1

Upvotes: 11

Views: 8532

Answers (2)

Matt
Matt

Reputation: 27853

Yes, if you use IPython 5.0 or above, It makes uses of Python Prompt Toolkit which does highlight code as you type, as well as support real, and sane multi-line edition.

To upgrade use :

pip install  ipython --upgrade

This is based on the work of Jonathan Slenders on ptpython:

python -m pip install ptpython

which provide 2 commands: ptpython and ptipython which should syntax highlight in your terminal. ptipython is a proof of concept so will likely miss some functionality of IPython, but push the interface a bit further.

Note that jupyter-console, which can connect to IPython as a kernel will also make use of prompt toolkit and highlight code as you type.

Upvotes: 6

Tobias Kienzler
Tobias Kienzler

Reputation: 27415

Jupyter, ipython's spin-off for notebooks, provides the command jupyter console, which is precisely what you (and I) are looking for.

Upvotes: 2

Related Questions