Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here


A better Python REPL

Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star half bd79095782ee4930099175e5ce7f4c89fa3ddabcd56fffcc7c74f6f2a2d46b27Star blank 374f33e4d622a2930833db3cbea26b5d03dc44961a6ecab0b9e13276d97d6682 (1 ratings)
Rated 3.5 out of 5
Subscribe to updates I use ptpython

Statistics on ptpython

Number of watchers on Github 2520
Number of open issues 120
Average time to close an issue about 1 month
Main language Python
Average time to merge a PR 4 days
Open pull requests 19+
Closed pull requests 20+
Last commit over 2 years ago
Repo Created over 5 years ago
Repo Last Updated almost 2 years ago
Size 906 KB
Organization / Authorjonathanslenders
Page Updated
Do you use ptpython? Leave a review!
View open issues (120)
View ptpython activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating ptpython for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)
What people are saying about ptpython Leave a review
better docs are needed


A better Python REPL


pip install ptpython

.. image ::

|Build Status|

Ptpython is an advanced Python REPL. It should work on all Python versions from 2.6 up to 3.5 and work cross platform (Linux, BSD, OS X and Windows).


Install it using pip:


pip install ptpython

Start it by typing ptpython.


  • Syntax highlighting.
  • Multiline editing (the up arrow works).
  • Autocompletion.
  • Mouse support. [1]
  • Support for color schemes.
  • Support for bracketed paste <>_ [2].
  • Both Vi and Emacs key bindings.
  • Support for double width (Chinese) characters.
  • ... and many other stuff.

[1] Disabled by default. (Enable in the menu.)

[2] If the terminal supports it (most terminals do), this allows pasting without going into paste mode. It will keep the indentation.

More screenshots

The configuration menu:

.. image ::

The history page and its help:

.. image ::


.. image ::

Embedding the REPL

Embedding the REPL in any Python application is easy:

.. code:: python

from ptpython.repl import embed
embed(globals(), locals())

Multiline editing

Multi-line editing mode will automatically turn on when you press enter after a colon.

To execute the input in multi-line mode, you can either press Alt+Enter, or Esc followed by Enter. (If you want the first to work in the OS X terminal, you have to check the Use option as meta key checkbox in your terminal settings. For iTerm2, you have to check Left option acts as +Esc in the options.)

.. image ::

Syntax validation

Before execution, ptpython will see whether the input is syntactically correct Python code. If not, it will show a warning, and move the cursor to the error.

.. image ::

Additional features

Running system commands: Press Meta-! in Emacs mode or just ! in Vi navigation mode to see the Shell command prompt. There you can enter system commands without leaving the REPL.

Selecting text: Press Control+Space in Emacs mode on V (major V) in Vi navigation mode.


It is possible to create a ~/.ptpython/ file to customize the configuration.

Have a look at this example to see what is possible: <>_

IPython support

Run ptipython (prompt_toolkit - IPython), to get a nice interactive shell with all the power that IPython has to offer, like magic functions and shell integration. Make sure that IPython has been installed. (pip install ipython)

.. image ::

Django support

django-extensions <>_ has a shell_plus management command. When ptpython has been installed, it will by default use ptpython or ptipython.


There is an experimental PDB replacement: ptpdb <>_.

Windows support

prompt_toolkit and ptpython works better on Linux and OS X than on Windows. Some things might not work, but it is usable:

.. image ::


Q: The Ctrl-S forward search doesn't work and freezes my terminal.

A: Try to run stty -ixon in your terminal to disable flow control.

Q: The Meta-key doesn't work.

A: For some terminals you have to enable the Alt-key to act as meta key, but you can also type Escape before any key instead.


  • BPython <>_
  • IPython <>_

If you find another alternative, you can create an issue and we'll list it here. If you find a nice feature somewhere that is missing in ptpython, also create a GitHub issue and maybe we'll implement it.

Special thanks to

  • Pygments <>_: Syntax highlighter.
  • Jedi <>_: Autocompletion library.
  • Docopt <>_: Command-line interface description language.
  • wcwidth <>_: Determine columns needed for a wide characters.
  • prompt_toolkit <>_ for the interface.

.. |Build Status| image:: :target:

.. |PyPI| image:: :target: :alt: Latest Version

ptpython open issues Ask a question     (View All Issues)
  • over 3 years Autocomplete for cd command not working correctly when compared to ipython
  • over 3 years Certain cd commands fail when syntax validation is on
  • over 3 years Cannot patch
  • over 3 years Wrong python version with python wheels
  • over 3 years Deprecation warning with autocomplete and RxPy
  • over 3 years Text starting from hash(#) is rendered as a comment.
  • over 3 years previous .ptpython symlink breaks initial startup
  • over 3 years Question: What limitation stops ptpython being an editor
  • over 3 years WISH: Scroll to parameter description in docstring
  • over 3 years How do I save it to a file?
  • over 3 years Segfault
  • over 3 years Please use XDG paths for and history by default
  • over 3 years Detecting background color on Windows
  • over 3 years ptipython does not run ipython startup script
  • over 3 years Moving to previous/next word using Ctrl + Left/Right not possible in vi mode
  • over 3 years Bracket highlighting is counterintuitive
  • almost 4 years How Do I Map Vi <ESC> to jj?
  • almost 4 years ptpython respects "repl.insert_blank_line_after_output = False", but ptipython doesn't appear to ...
  • almost 4 years 'Name' tokens hard to see on red-shifted screens
  • almost 4 years unperfect behaviour after a PyQtgraph test
  • almost 4 years unresponsive after gevent.monkey.patch_all()
  • almost 4 years ConEmu configuration
  • almost 4 years The second line of long (wrapped around) statements get masked by the 'signature' pop-up ...
  • almost 4 years Docstring scrolling with mouse enabled, returns to the top of the docstring ...
  • almost 4 years attach ptipython to open jupyter notebook server?
  • about 4 years Customize prompt color
  • about 4 years Add an option to run an asyncio event loop automatically
  • about 4 years Keep environment when exiting ptpython
  • about 4 years Colors are rendered incorrectly
  • about 4 years Support the same options as python and ipython
ptpython open pull requests (View All Pulls)
  • Prompt-toolkit upgrade.
  • Add clipboard configuration option. Resolve #43.
  • Closes issue #55
  • Support user_ns arg for compatibility with start_ipython
  • Make ptipython respect more config changes
  • Contribute a new gevent-compliant event loop (see issue #112)
  • Remove minor python version in entry point.
  • Eliminate extra validation after two newlines.
  • implement XDG Base Directory specification
  • extras_require not extra_require
  • Fixing isue 103 nd 83, docstring not scrollable in mouse mode.
  • ptipython: set __file__ when running interactively
  • Suppress all unknown Jedi errors.
  • exception handler for django.ImproperlyConfigured
  • Use Python3Lexer for python 3
  • implement XDG Base Directory specification
  • Switched broken badges to
  • Set last exception in sys module. Fixes #216
  • Don't crash history browser with no history and hitting space
ptpython list of languages used
Other projects in Python