1.python2.7的安装
解决依赖关系:
yum install gcc ncurses zlib zlib-devel patch python-devel openssl openssl-devel readline-devel -y
下载python2.7.9
tar xf python2.7.9.tar.gz
cd python2.7.9
./configure --prefix=/usr/local/python2.7.9
make && make install
ln -sv /usr/local/python2.7.9/bin/python /sbin/python
2.pip安装
安装pip首先下载安装 setuptools-0.6c11.tar ,
tar xf setuptools-0.6c11.tar
cd setuptools-0.6c11
python setup.py build
python setup.py install
3.安装pip pip-7.1.0.tar
tar xf pip-7.1.0.tar
cd pip-7.0.1
python setup.py install
ln -sv /usr/local/python2.7.9/bin/pip /sbin/pip
4.安装ipython
pip install ipython(此包不需要下载了 pip会自动找到下载并安装类似于yum) 这样默认安装的是 ipython-3.2.1
ln -sv /usr/local/python2.7.9/bin/ipython /sbin/ipython
5.安装readline
pip install readline
或者:
下载readline模块
https://pypi.python.org/packages/source/r/readline/readline-6.2.4.1.tar.gz#md5=578237939c81fdbc2c8334d168b17907
tar xf readline-6.2.4.1.tar.gz#md5\=578237939c81fdbc2c8334d168b17907.gz
python setup.py install
6.问题收集:
6.1:
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
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/sbin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-qvz6At/readline/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ui0PT9-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-qvz6At/readline
出现这个信息说明readline-devel patch 没有安装
6.2
ImportError: cannot import name HTTPSHandle
出现这个问题说明opensll openssl-devel 没有安装需要安装后并重新编译python
7.在python命令行中执行如下操作可以完成自动补全功能:
import readline, rlcompleter; readline.parse_and_bind("tab: complete")