macos 在 mac 上使用 readline 安装 ipython
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/726449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing ipython with readline on the mac
提问by Lorin Hochstein
I am using ipython on Mac OS 10.5 with python 2.5.1 (I would actually like to use ipython for 2.6.1, but it doesn't seem to be available?)
我在 Mac OS 10.5 上使用 ipython 和 python 2.5.1(我实际上想将 ipython 用于 2.6.1,但它似乎不可用?)
I installed ipython via easy_install. It works but is missing gnu readline (needed for nice searching of command line history with ctrl-R, etc.)
我通过easy_install安装了ipython。它可以工作,但缺少 gnu readline(需要使用 ctrl-R 等很好地搜索命令行历史记录)
I found a blog postand other sources saying this could be fixed by
我发现一篇博客文章和其他来源说这可以通过
sudo easy_install -f http://ipython.scipy.org/dist/ readline
sudo easy_install -f http://ipython.scipy.org/dist/ readline
However, this leads to build errors in readline.c
, particularly undeclared functions like rl_compentry_func_t
and rl_catch_signals
.
但是,这会导致 中的构建错误readline.c
,特别是像rl_compentry_func_t
和等未声明的函数rl_catch_signals
。
Has anyone seen these errors? Is there another way to get ipython installed with readline?
有没有人看到这些错误?有没有另一种方法可以使用 readline 安装 ipython?
采纳答案by hohonuuli
You can install everything you need with essentially one command using MacPorts. First download and install MacPorts from http://www.macports.org/.
您可以使用 MacPorts 通过一个命令安装所需的一切。首先从http://www.macports.org/下载并安装 MacPorts 。
Then just do the following in the terminal:
1) sudo port -v selfupdate
2) sudo port -v install py26-ipython
然后只需在终端中执行以下操作:1) sudo port -v selfupdate
2) sudo port -v install py26-ipython
That will install python2.6, ipython for python 2.6 and readline for you. The command to start ipython will be located at /opt/local/bin/ipython2.6
这将为您安装 python2.6、ipython for python 2.6 和 readline。启动 ipython 的命令将位于 /opt/local/bin/ipython2.6
回答by Lorin Hochstein
To install ipython on Snow Leopard or Lion without using MacPorts, you can simply do:
要在不使用 MacPorts 的情况下在 Snow Leopard 或 Lion 上安装 ipython,您只需执行以下操作:
sudo easy_install readline ipython
(Note that if you use the "pip" to install readline, then ipython won't see the readline library, not sure why).
(请注意,如果您使用“pip”来安装 readline,那么 ipython 将看不到 readline 库,不知道为什么)。
Edit:
编辑:
If you had ipython installed remove it with
如果您安装了 ipython 将其删除
sudo pip uninstall ipython
or
或者
pip uninstall ipython #for virtualenvs
Then make sure you have installed readline first and reinstall iptyhon
然后确保你已经安装了 readline 并重新安装 iptyhon
pip install readline ipython
For some reasons, if readline wasn't present during the installation, it will install itself without support for readline or it use the default mac readline.
由于某些原因,如果在安装过程中不存在 readline,它将在不支持 readline 的情况下自行安装,或者使用默认的 mac readline。
回答by Jiaaro
this worked for me (I'm using python 2.7, for other versions you'll need to edit):
这对我有用(我使用的是 python 2.7,对于其他版本,您需要编辑):
cd /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
sudo mv readline.so readline.so.bak
install readline however you want (pip, homebrew, macports, etc)
根据需要安装 readline(pip、homebrew、macports 等)
pip install -U readline
Success! and it works with virtualenv, and virtualenvwrapper, and no need to modify ipython :)
成功!它适用于 virtualenv 和 virtualenvwrapper,无需修改 ipython :)
回答by Anton Danilchenko
The only working way on MacOS Mavericks is to:
MacOS Mavericks 的唯一工作方式是:
- switch to your virtualenv
workon myproject_name
- delete readline and ipython (if you installed it before)
pip uninstall readline ipython
- install readline only via easy_install (pip - no work!)
easy_install readline
- finally install ipython with pip
pip install ipython
- 切换到你的 virtualenv
workon myproject_name
- 删除 readline 和 ipython(如果您之前安装过)
pip uninstall readline ipython
- 仅通过 easy_install 安装 readline(pip - 没有工作!)
easy_install readline
- 最后用pip安装ipython
pip install ipython
It's work well on my MacOS and tested a long time.
它在我的 MacOS 上运行良好,并经过了很长时间的测试。
回答by galpin
An alternative if you don't want to use ports. Caution: This is not upgrade safe.
如果您不想使用端口,另一种选择。注意:这不是升级安全的。
Install ipython
and readline
as normal:
安装ipython
并readline
照常:
sudo easy_install -f http://ipython.scipy.org/dist/ readline ipython
Find the full path to your readline
egg. For python 2.6 this will probably be:
找到你的readline
鸡蛋的完整路径。对于 python 2.6,这可能是:
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/readline-2.5.1-py2.6-macosx-10.3-fat.egg
Edit ipython
with your favourite text editor:
编辑ipython
用你喜欢的文本编辑器:
vim `which ipython`
Before the final line in the file sys.exit
, insert:
在文件的最后一行之前sys.exit
,插入:
sys.path.insert(0,'PATH_TO_READLINE_EGG')
Save and exit (:wq
).
保存并退出 ( :wq
)。
Check readline is working correct:
检查 readline 是否正常工作:
ipython
回答by Vasil
"I would actually like to use ipython for 2.6.1"
“我实际上想将 ipython 用于 2.6.1”
It is available. I'm using it with 2.6.1 on os x. You just need to install the official python 2.6.1 distribution, then install ipython with easy_install.
它是可用的。我在 os x 上将它与 2.6.1 一起使用。你只需要安装官方的python 2.6.1发行版,然后用easy_install安装ipython。