Search code examples
pythonpython-3.xreadlineipythoneasy-install

libedit/readline conflict with ipython 3.2.2 on OS X 10.7 Lion


I've been trying to set up ipython 3 (running 2.7 works fine) on a mac running Lion, but can't seem to get rid of the following error:

192:~ mlauria$ /Library/Frameworks/Python.framework/Versions/3.2/bin/ipython3
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages\
/IPython/utils/rlineimpl.py:96: RuntimeWarning: Leopard libedit detected - \
readline will not be well behaved including some crashes on tab completion, and \
incorrect history navigation. It is highly recommended that you install readline,\
which is easy_installable with: 'easy_install readline'
  RuntimeWarning)
Python 3.2.2 (v3.2.2:137e45f15c0b, Sep  3 2011, 17:28:59)

easy_install readline worked correctly to fix this on ipython 2.7, but this doesn't fix 3.2.


Solution

  • This is unfortunate as more and more Python distributions on OS X are being built with the Apple-supplied libedit in OS X rather than the GPL-licensed GNU readline library which Apple does not ship. For instance, current 64-bit/32-bit python.org installers for OS X use libedit while the 32-bit-only installers currently use readline since libedit was buggy on older versions of OS X. While the 32-bit-only installer for Python 3.2 can be installed on 10.7, it is problematic on 10.7 if you need to install any C extension modules, as that Python was built with the older 10.4u SDK and ppc archs which are not supported on 10.7. Ideally, iPython should be modified to work correctly with either libedit or readline. If there are Python bugs inhibiting that, bugs against Python itself should be filed. Also, perhaps the maintainers of the readline package on PyPI can be persuaded to build and put a 3.2 binary package out there.

    Otherwise you can build it yourself using their source distribution, assuming you have installed Xcode for Lion. If the Python 3.2 bin framework is not in your path, you'll need to do:

    $ export PATH=/Library/Frameworks/Python.framework/Versions/3.2/bin:$PATH
    

    Then if you have not already installed Distribute for Python 3.2:

    $ curl -O http://python-distribute.org/distribute_setup.py
    $ python3.2 distribute_setup.py
    

    Then download, build, and install the readline package from PyPI:

    $ easy_install-3.2 readline
    

    Or you could install a version of Python 3.2 from a third-party distributor like MacPorts which does provide a readline port (py32-readline) along with an iPython port.