通过上 一篇文章 脚本升级Python到2.7 之后发现一个问题, 在python/iPython交互器(命令行下)不能使用删除/上下键 无语法高亮 ,非常不方便。 检索相关信息,发现pypi有单独的readline模块 pip 安装License: Attribution-NonCommercial-ShareAlike 4.0 International
本文出自 Suzf Blog。 如未注明,均为 SUZF.NET 原创。
转载请注明:http://suzf.net/post/399
^_^[16:29:48][root@master01 ~]#pip install readline Collecting readline /usr/local/lib/python2.7/site-packages/pip-7.1.2-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Downloading readline-6.2.4.1.tar.gz (2.3MB) 100% |████████████████████████████████| 2.3MB 88kB/s Installing collected packages: readline Running setup.py install for readline Successfully installed readline-6.2.4.1源码安装
下载地址:https://pypi.python.org/pypi/readline/6.2.4.1 下载后解压安装python setup.py install 最后出错,提示如下 /usr/bin/ld: cannot find -lncurses collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1原因是未找到ncurses,需要安安装ncurses-devel包后再次安装readline,提示成功,enjoy! FAQ:
creating build/lib.linux-x86_64-2.7 gcc -pthread -shared build/temp.linux-x86_64-2.7/Modules/2.x/readline.o readline/libreadline.a readline/libhistory.a -lncurses -o build/lib.linux-x86_64-2.7/readline.so gcc: readline/libreadline.a: No such file or directory gcc: readline/libhistory.a: No such file or directory error: command 'gcc' failed with exit status 1 readline 是Python的一个内建模块,你看到这些错误信息是因为系统没有完成重建。可能是系统中缺少 patch 包。 你可以试试 yum install patch