time 2014-05-07 16:57:53 Mitchell Chu ' s Blog
OriginalHttp://blog.useasp.net/archive/2014/05/07/compile-and-install-python-2-dot-7-dot-6-on-centos.aspx ThemesPython Centos Linux Commands
Under CentOS When upgrading to 2.7.6, there is no installation package installed directly, only the source code compiled to install Python version 2.7.6. This is a process record for compiling and installing Python2.7.6.
Development tools is installed in the CentOS system. To compile and install Python, execute the following code:
$ pushd/usr/local/src$ sudo mkdir python$ sudo chown $USER python$ cd python$ wget https://www.python.org/ftp/python/2.7. 6/python-2.7. 6.tgz$ tar zxvf python-2.7. 6.TGZ$ cd python-2.7. 6$. /configure--prefix=/usr/local/python-2.7. 6 &&make$ sudo make install
Code procedures:
1. /usr/local/src
Create the Python folder and set the Python folder owner to the current user (not root)
2. Go to the created Python directory and download the python2.7.6 source code package from the official website.
3. (non-mandatory) if you want to verify the consistency of the package, you can download the sig file on the official website, and through the PGP check file, you can also verify the downloaded compressed package by the MD5 available on the website. For more information on verification, refer to the integrity of the check file under Linux (MD5,SHA1,PGP). This code ignores this procedure.
4. Unzip the package into the current directory and enter the Python-2.7.6
directory
5. Configure Python and compile. This step only uses --prefix
parameters to indicate the installation path.
6. Install Python
The above is a rough process in the case of a successful Python compilation installation, but when I compile it, Python has the following message:
Found: _bsddb _sqlite3 _ssl _tkinter bsddb185 bz2 dbm gdbm readline sunaudiodevmodule' s name.
Of course, each machine because of different configuration, compile error message will be different, such as online someone's error is the following:
Found: _bsddb _curses_curses_panel _sqlite3 _ssl_tkinter dl Gdbmimageop ReadLine Sunaudiodev zlibmodule' s name.
Regardless of the error message, meaning is very clear, we compile, the system does not have the means to find the corresponding module information, in order to resolve these errors, we need to install the dependency package in advance, these dependencies are listed as follows (not necessarily complete):
Module |
Depend on |
Description |
_bsddb |
Bsddb |
Interface to Berkeley DB Library. Interface to the Berkeley database |
_curses |
Ncurses |
Terminal handling for Character-cell displays. |
_curses_panel |
Ncurses |
A panel stack extension for curses. |
_sqlite3 |
Sqlite |
DB-API 2.0 interface for SQLite databases. Sqllite,centos can be installed Sqlite-devel |
_ssl |
openssl-devel.i686 |
Tls/ssl wrapper for socket objects. |
_tkinter |
N/A |
A thin object-oriented layer on top of TCL/TK. If you do not use a desktop program, you can ignore Tkinter |
bsddb185 |
Old BSDDB Module |
Old BSDDB module, can be ignored. |
bz2 |
bzip2-devel.i686 |
Compression compatible with bzip2. Bzip2-devel |
Dbm |
Bsddb |
Simple "Database" interface. |
Dl |
N/A |
Call C functions in shared objects. Python2.6 started, has been deprecated. |
gdbm |
gdbm-devel.i686 |
GNU ' s reinterpretation of dbm |
Imageop |
N/A |
Manipulate RAW image data. has been deprecated. |
ReadLine |
Readline-devel |
GNU ReadLine Interface |
Sunaudiodev |
N/A |
Access to Sun audio hardware. This is for Sun platform, can be ignored under CentOS |
Zlib |
Zlib |
Compression compatible with gzip |
Under CentOS, these dependency packages can be installed: readline-devel,sqlite-devel,bzip2- devel.i686,openssl-devel.i686,gdbm-devel.i686,libdbi-devel.i686,ncurses-libs,zlib-devel.i686. After you have completed these installations, you can compile them again, and the module errors specified in the table above as deprecated or ignored can be ignored.
After the compilation is complete, you can then install Python to the specified directory in the sixth step above. After the installation is complete, we can see if Python is installed properly under the installation directory.
$ pushd/usr/local/python-2.7. 6/bin$ python--version$ sudo mv/usr/bin/python/usr/bin/python.old$ sudo ln-s python/usr/bin/python$ p OPD$ python-V"s/#\!\/usr\/bin\/python/#\!\/usr\/bin\/python.old/"/usr/bin/yum
1. We go to the bin directory under the installation path and view the installed version (version 2.7.6)
2. Rename the existing Python version to backup
3. Create a new version of Python to /usr/bin
replace the original python in the directory
4. Test the System Python version (should be the new 2.7.6)
5. If Yum does not work properly, you can simply replace the Python reference with the original Python path via sed.
At this point, complete the Python update compilation installation. If you want to complete the automatic installation, you can save the previous code as a shell script file-it is important to note that you may need to add the installation scripts for each module, which is installed through Yum. You can also refer to the article in 2, which contains the script files that are automatically installed.
Reference:
1. Python official website
2. Install Python 2.7.2 on CentOS 5.2, including automated installation scripts.
Reproduced Build and install Python2.7.6 under CentOS