Standard distributions of CentOS 6.5 include Python 2.6.6, which often lacks compatibility with modern tools such as IPython 2.3. This tool requires a minimum version of Python 2.7 or Python 3.3+. To resolve this dependency, the interpreter must be compiled from source and intgerated into the system path while preserving existing system utilities.
1. Installing Development Dependencies Compiling Python generally requires GCC, but specific standard library modules need header files. Install the necessary development packages to support encryption and database interfaces.
yum install -y zlib-devel openssl-devel sqlite-devel gcc
2. Retrieving Source Code Download the stable release archive. Version 2.7.8 serves as the target build in this scenario.
wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
tar xzf Python-2.7.8.tgz
cd Python-2.7.8
3. Compilation Configuration
Install the interpreter into a dedicated directory (/usr/local/python2.7) to isolate it from OS-managed binaries. This prevents conflicts during system updates.
./configure --prefix=/usr/local/python2.7 --enable-shared
make -j$(nproc)
sudo make install
4. Managing System Symlinks
Directly replacing the default python binary can disrupt package management tools like yum. Safely rename the original binary first, then link the new version.
sudo mv /usr/bin/python /usr/bin/python2.6.bak
sudo ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python
Verify the successful switch using:
python --version
5. Restoring Package Manager Compatibility
The yum command defaults to the old Python executable. Modify its shebang line to insure it continues to use the legacy version (2.6).
sudo sed -i '1s|^#!/usr/bin/python$|#!/usr/bin/python2.6|' /usr/bin/yum
6. Configuring Pip and Setuptools Bootstrap the installer for setuptools and pip to enable third-party package management.
wget https://bootstrap.pypa.io/get-pip.py
/usr/local/python2.7/bin/python get-pip.py
Expose the new executbales globally by creating symbolic links.
sudo ln -s /usr/local/python2.7/bin/pip /usr/bin/pip
sudo ln -s /usr/local/python2.7/bin/easy_install /usr/bin/easy_install
7. Deploying IPython
Utilize pip to install the interactive shell environment.
sudo pip install ipython
sudo ln -s /usr/local/python2.7/bin/ipython /usr/bin/ipython
8. Enabling Readline Support Enhance terminal capabilities such as history navigation and code completion by installing the underlying C library and the Python wrapper.
sudo yum install -y readline-devel patch
sudo pip install readline
Once configured, IPython supports syntax highlighting and advanced editing features.