CentOS python 2.7.3 installation bz2 extension method

Source: Internet
Author: User
Tags bz2 centos

Installing Node.js in the CentOS system encountered the following error

The code is as follows Copy Code

Importerror:no module named bz2:
File "/disk/src/node-v0.6.12/deps/v8/sconstruct", line 37:
Import JS2C, Utils
File "/disk/src/node-v0.6.12/deps/v8/tools/js2c.py", line 36:
Import bz2
waf:leaving directory '/disk/src/node-v0.6.12/out '
Build failed:-> task failed (err #2):
{task:libv8.a sconstruct-> libv8.a}
Make: * * * [Program] Error 1

The error is because Python does not have bz2 extensions, install BZ2, and then reinstall Python.

The code is as follows Copy Code

Yum Install-y bzip2*
Cd.. /python-2.7.3/modules/zlib
./configure
Make
Make install
Cd.. /.. /
Python setup.py Install

add: because the CentOS default version is python2.4 so we can refer to the following methods to upgrade in place python2.7.3 can oh.

The following starts compiling the Python 2.7.3 version

The code is as follows Copy Code

Wget-c http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2--no-check-certificate
Tar jxvf python-2.7.3.tar.bz2
CD Python-2.7.3
./configure
Make
Make install

The default installation path for python2.7 is/usr/local/lib/python2.7, after the installation is complete, check to see if the version is correct

The code is as follows Copy Code

$/usr/local/bin/python2.7-v
Python 2.7.3

Normally, even if the python2.7 installation is successful, the system's default pointing Python is still 2.4.3, so you need to point the system's default Python to version 2.7 because the Yum in CentOS is based on python2.4.3 to work properly, so do not uninstall Python 2.4.3 version.

The code is as follows Copy Code

Mv/usr/bin/python/usr/bin/python.bak
Ln-s/usr/local/bin/python2.7/usr/bin/python

Verify the Python point is successful

The code is as follows Copy Code

$ python-v
Python 2.7.3

Python defaults to the 2.7 release, the way to ensure that Yum can work correctly

Open/usr/bin/yum, the first line of the display #/usr/bin/python modified to #/usr/bin/python2.4 (let Yum or to call python2.4), save the changes can be.

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.