CentOS Compile and install Perl, Python, and problem solving __python

Source: Internet
Author: User
Tags bz2 mkdir readline install perl

First, install Perl


[Root@centos ~]# wget http://www.cpan.org/src/5.0/perl-5.16.0.tar.gz

[Root@centos ~]# tar zxvf perl-5.16.0.tar.gz

[Root@centos ~]# CD perl-5.16.0

[Root@centos perl-5.16.0]# mkdir-p/usr/local/perl
[Root@centos perl-5.16.0]# ls/usr/local/

The compilation parameter uses the default

[Root@centos perl-5.16.0]#./configure-des-dprefix=/usr/local/perl/

[Root@centos perl-5.16.0]# make

[Root@centos perl-5.16.0]# make Test

[Root@centos perl-5.16.0]# make install
At the end of this installation, test for proper installation.
[Root@centos ~]# Perl-v
This is Perl, v5.8.8 built for I386-linux-thread-multi
Copyright 1987-2006, Larry Wall
Perl May is copied only under the terms of either the artistic License or the
GNU general public License, which may is found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should is found on
This is the system using "Man Perl" or "Perldoc perl". If you are have access to the
Internet, point your browser at http://www.perl.org/, the Perl home Page.


Second, install Python, and problem solving


[Root@centos ~]# wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2

[Root@centos ~]# tar jxvf python-2.7.3.tar.bz2

[Root@centos ~]# CD Python-2.7.3

[Root@centos perl-5.16.0]# mkdir-p/usr/local/python
[Root@centos perl-5.16.0]# ls/usr/local/

[Root@centos python-2.7.3]#./configure--prefix=/usr/local/python/

[Root@centos python-2.7.3]# make

Problem encountered:

Python build finished, but the necessary bits to build this modules were not found:
_BSDDB _sqlite3 _tkinter
bsddb185 bz2 dbm
GDBM ReadLine Sunaudiodev
To find the necessary bits, look into setup.py in Detect_modules () for the module ' s name.


Failed to builds these modules:
_curses _curses_panel

By the prompts, the first to solve the failed to compile the module _curses, _curses_panel This is because the relevant library files are not found, installation ncurses can be resolved, but ncurses is more common, should have been installed before, the system should not have no, also regardless of, the use of Yum installation.

[Root@centos python-2.7.3]# yum install ncurses ncurses-devel

Make again

[Root@centos python-2.7.3]# make

Tips:

Python build finished, but the necessary bits to build this modules were not found:
_BSDDB _sqlite3 _tkinter
bsddb185 bz2 dbm
GDBM ReadLine Sunaudiodev
To find the necessary bits, look into setup.py in Detect_modules () for the module ' s name.

As you can see from the prompts, the previous module compiles normally, but the system does not have to be prompted for the necessary bits. This problem bothered me for a long time, in the Internet to search a lot of information, also did not find a better solution, their own attempt to install a number of related libraries, and still appear this hint. But some documents on the Web mention this problem is very common, can be ignored. I tried many times after the failure, but also to ignore, and later proved that no problem, but this also for me to install gitosis error row caused trouble. Install directly after ignoring.

PS: Some of the necessary modules or to install, if you can not solve the bold skip, later encountered problems, prompted Python a necessary module is not installed to solve.

[Root@centos python-2.7.3]# make install

[Root@centos python-2.7.3]# Python-v

Python 2.4.3

At this point, the Python version is 2.4, because the Python version in the CentOS system defaults to 2.4. Replace the default version:

[Root@centos bin]# mv/usr/bin/python/usr/bin/python2.4//May python2.4 already exist

[Root@centos bin]# ln-s/usr/local/python/bin/python/usr/bin/python

[Root@centos bin]# which Python
/usr/bin/python
[Root@centos bin]# Python-v
Python 2.7.3

After the upgrade is installed Yum will not be able to use, because Yum is using version 2.4, at this time Yum will have the following prompts

[Root@centos bin]# Yum Update
There was a problem importing one of the Python modules
Required to run Yum. The error leading to this problem is:


No module named Yum


Please install a package which provides this module, or
Verify that's the module is installed correctly.


It ' s possible that the above module doesn ' t match the
Current version of Python, which is:
2.7.3 (Default, Aug 12 2012, 20:23:42)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)]


If you are cannot solve this problem yourself
The Yum FAQ at:
Http://wiki.linux.duke.edu/YumFaq

Modify the Yum profile to be able to identify Python under version 2.4

[Root@centos bin]# Vi/usr/bin/yum
Modify the #!/usr/bin/python to #!/usr/bin/python2.4

It is normal to run Yum again.

----------------------------------Supplement -2012-08-26---------------------------------------------

The original python was renamed python2.4.1 before because/usr/bin/already had python2.4. Modify/usr/bin/yum is also changed #!/usr/bin/python2.4 run Yum normal, but each boot prompt:

Traceback (most recent call last):
File "/usr/lib/wicd/wicd-daemon.py", line <module>
Import Dbus
Importerror:no module named Dbus

Later modified/usr/bin/yum for #!/usr/bin/python2.4.1 boot Normal, no this prompt.

So if/usr/bin/already have python2.4 MV, it is recommended not to overwrite, but diff/usr/bin/python2.4/usr/bin/python2.4.1 no output, modify/usr/bin/yum for #!/usr/bin/ python2.4 boot still prompts the error, again leave doubt.

--------------------------------------Supplemental End----------------------------------------------------

------------------------------------------------------------------------------------------------------

The document is over, and the last one to quote two blogs as a memo:

First, http://www.cnblogs.com/lexus/archive/2012/02/23/2365660.html

Update: The method of installing zlib above failed, originally Python 2.7 had to install Zlib library First:

Cd/opt/python-2.7.2/modules/zlib
./configure make && make install install zlib

Second, http://blog.sina.com.cn/s/blog_814b01e70100z6h7.html

Here, we can see clearly that the ReadLine module build failed and I checked to see if there were any errors in the build, and I found that the build process had the following inconspicuous error:

Building ' readline ' extension

Gcc-fpic-fno-strict-aliasing-g-o2-dndebug-g-fwrapv-o3-wall-wstrict-prototypes-i.-iinclude-i./include-i/usr/l Ocal/include-i/tmp/python-2.7.2/include-i/tmp/python-2.7.2-c/tmp/python-2.7.2/modules/readline.c-o build/ Temp.solaris-2.10-sun4u-2.7/tmp/python-2.7.2/modules/readline.o

/tmp/python-2.7.2/modules/readline.c:758:warning: ' On_completion_display_matches_hook ' defined but not used

Gcc-shared build/temp.solaris-2.10-sun4u-2.7/tmp/python-2.7.2/modules/readline.o-l/usr/lib/termcap-l/usr/local/ Lib-l.-lreadline-lncurses-lpython2.7-o build/lib.solaris-2.10-sun4u-2.7/readline.so

Text Relocation remains

This error is similar to Python's own module, with its defined ReadLine compilation, which conflicts with the ReadLine I specify when I config, and I don't know why I can't use the build. While I was in the configure, I added a lot of parameters, such as ldflags, such as Cppflags, as well as my vi setup.py file, in # Platform-dependent module source and include Directories

Defines the location of the ReadLine, but we still cannot load the readline.

My colleagues and I looked through a lot of documents and materials, and finally we found that there was a document saying that we needed to modify a profile and that the Python-worthy module would call it normally.

In the Python installation directory, there is a directory named module, which has a setup.dist configuration file, the basic need to load the module can be found inside.

VI This file, we find ReadLine, will find a simple description, and indicate that if you want to define a new location, we can modify the parameters by

# GNU ReadLine. Unlike previous Python incarnations, GNU ReadLine is

# now incorporated in a optional module, configured in the Setup file

# Instead of by a configure script switch. Have to insert a

# l option pointing to the directory where Libreadline.* lives,

# and you could have to change-ltermcap to-ltermlib or perhaps remove

# it, depending on your system--the GNU readline instructions.

# It's okay is a shared library, too.

#readline Readline.c-lreadline–ltermcap

Instead: (Remove the annotation character, specify its include and Lib location)

ReadLine Readline.c-i/proj/application/tools/readline-5.2-sol/include-l/proj/application/tools/readline-5.2-sol /lib-r/proj/application/tools/readline-5.2-s

Ol/lib-lreadline–ltermcap

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.