CentOS underneath Python was upgraded to 2.7.6, no installation package was found, and the Python 2.7.6 version can only be installed through source code compilation. This is a process record for compiling and installing Python2.7.6.
Development tools are installed in the CentOS system. To compile and install Python, execute the following code:
The code is as follows |
Copy 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 procedure:
1. Create the Python folder in/usr/local/src 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. (not necessary) if you want to check the consistency of the package, you can download the sig file on the official website, and through PGP Check file, can also be provided through the official website of the MD5 to verify the compression package. For more information about checksums, check the integrity of the files under Linux (MD5,SHA1,PGP). This code ignores this procedure.
4. Extract the compressed package to the current directory and enter the Python-2.7.6 directory
5. Configure Python and compile. This step only uses the--prefix parameter to indicate the installation path.
6. Install Python
The above is a general process in the case of Python compiling the installation smoothly, but when I compile, Python appears with the following message:
The code is as follows |
Copy Code |
Python build finished, but the necessary bits to build this modules were not found: _BSDDB _sqlite3 _ssl _tkinter bsddb185 bz2 DBM GDBM ReadLine Sunaudiodev To find the necessary bits, look into setup.py in Detect_modules () for the module ' s name.
|
Of course, each machine because of different configuration, compile the error message will also be different, such as online someone's error is the following:
The code is as follows |
Copy Code |
Python build finished, but the necessary bits to build this modules were not found: _BSDDB _curses _curses_panel _sqlite3 _ssl _tkinter bsddb185 bz2 dbm DL GDBM Imageop ReadLine Sunaudiodev zlib To find the necessary bits, look into setup.py in Detect_modules () for the module ' s name. |
Regardless of the error message, the meaning is very clear, we compile, the system has no way to find the corresponding module information, in order to resolve these errors, we need to install the dependent package in advance, these dependent packages correspond to the list below (not necessarily complete):
Module |
Depend on |
Description |
_bsddb |
Bsddb |
Interface to Berkeley DB Library. Interfaces for Berkeley databases |
_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 |
The 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 discarded. |
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 the Sun platform, CentOS can be ignored |
Zlib |
Zlib |
Compression compatible with gzip |
After the compilation is complete, you can then install Python to the specified directory in step sixth above. After the installation is complete, we can go to the installation directory to see if Python is properly installed.
The code is as follows |
Copy Code |
$ 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 $ popd $ python-v $ sudo sed-i "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 is 2.7.6)
2. Rename the existing Python version of the backup
3. Create a new version python to the/usr/bin directory instead of the original Python
4. Test system Python version (should be the new 2.7.6)
5. If Yum does not work at this point, you can simply replace the Python reference in the original Python path with SED.
At this point, complete the update compilation of Python installation work. If you want to complete the automatic installation, you can save the previous code as a shell script file--note that you may need to add the installation scripts for each module, and this article is installed through Yum. You can also use the article in reference 2 to include the automatically installed script file.