当我在我的osx上安装ipython并运行它时,我收到以下警告:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
site-packages/IPython/utils/rlineimpl.py:96:
RuntimeWarning: Leopard libedit detected - readline will not be wel
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'
我已经安装了readline,并且不使用最初安装在/Library/Frameworks/Python.framework/Versions/2.7/bin/python$
中的系统python。 /usr/bin/python
指向版本2.7,如下所示
uname -a
Darwin macbook.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7
16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
$sudo pip install readline ipython
$ipython --version
0.11
$/usr/bin/python --version #
Python 2.7.1
$which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
我已在Python sys.path modification not working中阅读了该问题 - 我向/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/readline-6.2.1-py2.7.egg-info
添加了/Library/Frameworks/Python.framework/Versions/2.7/bin/ipython
,现在看起来像这样:http://pastebin.com/raw.php?i=dVnxufbS
但我无法弄清楚为什么会收到以下错误:
File
"/Library/Frameworks/Python.framework/Versions/2.7/bin/ipython",
line 9
sys.path.insert(0,"/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/readline-6.2.1-py2.7.egg-info")
我不认为上述路径是一个问题,我的目标是让ipython工作而不会抱怨readline,即使它已经安装并正确导入。
答案 0 :(得分:41)
当pip安装readline时,它永远不会被导入,因为readline.so位于site-packages中,最终位于lib-dynload
中的libedit System one之后(OSX Python路径顺序很奇怪)。 easy_install -a readline
实际上会安装可用的readline。
所以你可以使用easy_install,或者使用pip和muck about你的PYTHONPATH / sys.path(这实际上意味着:不要使用PIP)。
关于IPython列表的更多细节(虽然关于这个问题确实没有特定的IPython):http://mail.scipy.org/pipermail/ipython-user/2011-September/008426.html
编辑:关于virtualenv的额外说明。
virtualenv中有一个错误< 1.8.3,创建环境时,readline无法正确暂存。
答案 1 :(得分:1)
如果你不介意用你的PYTHONPATH来解决问题,那么你可以在这里摆脱那个讨厌的警告:
# 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
如果您正在使用Django,可以将其放在site-packages / django / core / management / commands / shell.py的ipython
方法中,以便在运行{{1}时运行它}。
答案 2 :(得分:0)
对此答案的未来读者的补充说明。
在我的情况下 - 运行IPython的MacPorts安装 - / opt / local / bin /中有几个版本的easy_install
,但没有指向最新版本的非版本符号链接。执行easy_install-2.7 -a readline
工作。
答案 3 :(得分:0)
我还使用brew
安装的ipython
,但遇到类似问题。
⚡ 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)
解决方案:
⚡ 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
结果:
⚡ 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