Methods for upgrading Python2.6 to Python2.7 under the CentOS 6.X system _python

Source: Internet
Author: User
Tags sqlite

First step: Upgrade Python

CentOs 6.x's system default installed Python version is 2.6.x, want to upgrade to python2.7.x, from the official download source files, and then unzip, compile

wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
unxz python-2.7.10.tar.xz
tar-vxf Python-2.7.10.tar

Executing the above command will extract the Python-2.7.10 this folder, enter the directory and execute the following command to configure

./configure--enable-shared--enable-loadable-sqlite-extensions--with-zlib

--enable-loadable-sqlite-extensionsThis is an extension of the SQLite, with this option if needed.

Before compiling, you need to modify the setup file to remove the annotations we need to compile the zlib

VI./modules/setup

Locate and #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz Save the annotation and then compile and install it

Make && make install

After installing the Python2.7 we need to back up the Python2.6 and then modify the Yum configuration, and if you don't do this, executing the Yum command will prompt you for the wrong version of Python. Perform the following command, back up the Python2.6, and then create a soft link for Python2.7:

mv/usr/bin/python/usr/bin/python2.6.6
ln-s/usr/local/bin/python2.7/usr/bin/python

Then edit /usr/bin/yum to change the first line #!/usr/bin/python to#!/usr/bin/python2.6.6

There is no previous error message executing the yum command. We perform python-v view version information, if an error occurs

Error while loading shared Libraries:libpython2.7.so.1.0:cannot open Shared object file:no such file or directory

Edit configuration file

Vi/etc/ld.so.conf

Add a new line of content /usr/local/lib , save the exit, and then

/sbin/ldconfig 
/sbin/ldconfig-v

Step Two: Install Pip

Download the latest version of the PIP, and then install

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

Find the location of the PIP

Whereis pip

Find the path to pip2.7 and create a soft chain for it as the default boot version of the system

Ln-s/usr/local/bin/pip2.7/usr/bin/pip

Pip installed, now you can use it to install a variety of requirements of the package:)

Step Three: Install Scrapy

pip install scrapy it's just OK.

Summarize

The above is the CentOS 6.X system upgrade Python2.6 to Python2.7 all the steps, we have learned? Hope this article for everyone's study or work to bring certain help.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.