Skip to content

tkf/IPython.jl

Repository files navigation

Launch IPython in Julia

Build Status codecov.io

Example REPL session

Usage

Run using IPython and then type . in empty julia> prompt or run IPython.start_ipython(). You can switch back to Julia REPL by backspace or ctrl-h key (like other REPL modes). Re-entering IPython keeps the previous state. Use pre-defined Main object to access Julia namespace from IPython. Use py"..." string macro to access Python namespace from Julia.

Note: First launch of IPython may be slow.

Requirements

Julia

  • PyCall

Python

  • Python 3.7 or above
  • IPython 7.0 or above

Accessing Julia from Python

If simple Main.eval("...") and Main.<name> accessor is not enough, PyJulia is a nice way to access Julia objects from Python. For example, you can import any Julia package from Python:

>>> from julia import Base
>>> Base.banner()

For more advanced/experimental Julia-(I)Python integration, see ipyjulia_hacks.

Configuration

Julia-mode like prompt

If you want IPython prompt to look like a part of Julia prompt, then add the following snippet in ~/.ipython/profile_default/ipython_config.py:

try:
    from ipython_jl.tools import JuliaModePrompt
except ImportError:
    pass
else:
    c.TerminalInteractiveShell.prompts_class = JuliaModePrompt

Then the prompt would then look like ipy 1> instead of In [1]:. It also removes Out[1]. Note that above setting does not change your normal IPython prompts.