When I install ipython on my osx and run it, I get the following warning:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
site-packages/I
If you don't mind mucking around with your PYTHONPATH, here's how you can get rid of that pesky warning:
# move site-packages to the front of your sys.path
import sys
for i in range(len(sys.path)):
if sys.path[i].endswith('site-packages'):
path = sys.path.pop(i)
sys.path.insert(0, path)
break
If you're using Django, you can put this in the ipython
method of your site-packages/django/core/management/commands/shell.py so that it runs when you run ./manage.py shell
.
Additional note to future readers of this answer.
In my case -- running a MacPorts installation of IPython -- there were several versions of easy_install
in /opt/local/bin/, but no non-versioned symlink pointing to the most current. Performing easy_install-2.7 -a readline
worked.
When pip installs readline, it will never be imported, because readline.so goes in site-packages, which ends up behind the libedit System one, located in lib-dynload
(OSX Python path order is very odd). easy_install -a readline
will actually install usable readline.
So you can either use easy_install, or use pip and muck about with your PYTHONPATH/sys.path (which essentially means: DO NOT USE PIP).
A bit more detail on the IPython list (though there really isn't anything IPython-specific about this issue): http://mail.scipy.org/pipermail/ipython-user/2011-September/008426.html
EDIT: extra note about virtualenv.
There is a bug in virtualenv < 1.8.3, where readline would not be properly staged when you create an env.
I am also using brew
installed ipython
and I had a similar issue.
⚡ easy_install-3.7 -a readline
Searching for readline
Reading https://pypi.org/simple/readline/
Download error on https://pypi.org/simple/readline/: unknown url type: https -- Some packages may not be found!
Couldn't find index page for 'readline' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
Download error on https://pypi.org/simple/: unknown url type: https -- Some packages may not be found!
No local packages or working download links found for readline
error: Could not find suitable distribution for Requirement.parse('readline') (--always-copy skips system and development eggs)
Solution:
⚡ brew install readline
Updating Homebrew...
Warning: readline 7.0.5 is already installed, it's just not linked
You can use `brew link readline` to link this version.
⚡ brew link readline
Warning: readline is keg-only and must be linked with --force
⚡ brew link readline --force
Linking /usr/local/Cellar/readline/7.0.5... 16 symlinks created
Result:
⚡ ipython
Python 3.7.2 (default, Dec 27 2018, 07:35:06)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.
>>> ~/.pyrc loaded successfully