Skip to content

Frequently asked questions

Min RK edited this page Feb 5, 2014 · 9 revisions

FAQ

This is the IPython Frequently Asked Questions page.

We are in the process of moving this type of Q&A to the IPython tag on stackoverflow. Please post any new questions there.

I would like to know if there is an easy way to install parallel versions of ipython? Actually, I would like to be able to use ipython with python 2.7 which is the default on my machine, and with python3.3 (compiled by hand).

Answer: The easiest way to do this is with virtual environments:

$ mkvirtualenv -p python2.7 py27
$ mkvirtualenv -p python3.3 py33
$ workon py33
$ pip install ipython
$ workon py27
$ pip install ipython

Answer: The terminal-based shell should run on any interpreter which complies with the necessary version of Python. IPython 0.11 requires Python 2.6 or above, and as of June 2011, IronPython and PyPy both support this.

The most likely problems would come from Readline and from using the undocumented sys._getframe() function. On Windows we ship our own pyreadline, which might also work under IronPython. PyPy ships its own readline module, which should now work.

If IPython does not work under a supported interpreter, please file a bug.

Under some circumstances, using the arrow keys to navigate your input history can cause a complete crash of the Python interpreter.

Answer: This is due to a bug in the readline library (libedit) from the official builds. The easiest way to address this is to install readline separately:

easy_install -a readline

Yes, it most definitely does!

  • pip install ipython works pretty much everywhere.
  • The classic python setup.py install still works, of course.
  • pip install -e git+https://github.com/ipython/ipython#egg=ipython is the quickest way to install from git master.

Answer: The color escapes used by IPython are not correctly interpreted by default by many common pagers ('less' included). The manual describes here the problem and its solution in detail, but the short version is that your bashrc file should contain:

export PAGER=less
export LESS=-r

Answer: The latter, I'm afraid, but there's a workaround. The reason, deep down, is a clash between ipython's modification of sys.displayhook so you get nice output prompts, and the fact that the exec builtin is internally hardcoded to run sys.displayhook. So ipython collides with doctest (which uses 'exec') and all hell breaks loose.

Here's the workaround. First, your error (I called your file 'dtest'):

In [5]: doctest.testmod(dtest)
Out[5]: 1
**********************************************************************
File "dtest.py", line 8, in dtest
Failed example:
    x()
Expected:
    1
Got nothing
**********************************************************************
1 items had failures:
   1 of   3 in dtest
***Test Failed*** 1 failures.
Out[5]: (1, 3)

Now the workaround:

In [6]: iphook = sys.displayhook
In [7]: sys.displayhook = sys.__displayhook__
In [8]: doctest.testmod(dtest)
*** DocTestRunner.merge: 'dtest' in both testers; summing outcomes.
(0, 3)

Now you can reactivate ipython's displayhook if you want:

In [9]: sys.displayhook = iphook

You could wrap this little sys.displayhook dance in a utility function to ease things up.

Answer: Yes it is still a bit of effort.

  • download IronPython 2.7.4
  • add your C:/Program Files/IronPython 2.7 folder into PATH
  • download modified pyreadline install from source: ipy setup.py install
  • download ipython (1.0 or 1.1), install from source: ipy setup.py install
  • replace C:/Program Files/IronPython/Lib/site-packages/IPython/external/pexpect/_pyexpect.py with one from https://github.com/paweljasinski/ipython/blob/ironpython-hack/IPython/external/pexpect/_pexpect.py
  • make sure you HOME environment variable is set to something reasonable
  • start: ipy.exe -X:Frames "c:/Program Files/IronPython 2.7/Scripts/ipython"

Note: it does not work with cygwin terminal

There is also a bug fix which didn't make to the 2.7.4. Either you need to rebuild 2.7.4 from sources or modify ipython as suggested.

As mentioned at the top: We are in the process of moving this type of Q&A to the IPython tag on stackoverflow. Please post any new questions there.

Clone this wiki locally