I. Installation of python2.7
1, download
Available for download from http://www.python.org/
The code is as follows |
Copy Code |
#wget http://www.python.org/ftp/python/ |
2, decompression
The code is as follows |
Copy Code |
#tar JXVF python-2.7.6.tar.bz2 |
3. Installation:
The code is as follows |
Copy Code |
#cd Python-2.7.6 #./configure--prefix=/usr/local/python2.7--enable-shared #make #make Install |
When a libpython2.7.so.1.0 error occurs:
The code is as follows |
Copy Code |
#./python ./python:error while loading shared libraries:libpython2.7.so.1.0:cannot open Shared object file:no such file or Direc Tory #/usr/local/python2.7/bin/python2.7 /usr/local/python2.7/bin/python2.7:error while loading shared libraries:libpython2.7.so.1.0:cannot open Shared object File:no such file or directory Libpython2.7.so.1.0 the solution to the error: #vi/etc/ld.so.conf Add/usr/local/python2.7/lib #/sbin/ldconfig #/sbin/ldconfig-v |
4. Using the newly installed Python:
The code is as follows |
Copy Code |
#mv/usr/bin/python/usr/bin/python_old #ln-S/usr/local/python2.7/bin/python2.7/usr/bin/python # python Python 2.7.2 (default, Dec 29 2013, 13:29:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type ' help ', ' copyright ', ' credits ' or ' license ' for the more information. >>> |
Second, install mysqldb for Python
The code is as follows |
Copy Code |
# Unzip Mysqldb-python.zip # CD mysqldb1-master/ # which Mysql_config /usr/local/mysql/bin/mysql_config # VIM Site.cfg modified as follows: Mysql_config =/usr/local/mysql/bin/mysql_config # python setup.py Build # python setup.py Install |
Www.111cn.net
Common Error Resolution:
1. If you compile Python, the following problems occur
/usr/bin/ld:cannot find-lpython2.7
Collect2:ld returned 1 exit status
Error:command ' gcc ' failed with exit status 1
Use the following procedure to process:
A. Check and install the Python-devel package
# yum-y Install Python-devel
B. Establish a soft connection to the Libpython2.7.so library file under/usr/lib
Execute under 32-bit server
# ln-s/usr/local/python2.7/lib/libpython2.7.so/usr/lib/libpython2.7.so
Execute under 64-bit server
# ln-s/usr/local/python2.7/lib/libpython2.7.so/usr/lib64/libpython2.7.so
C. Check to see if the/etc/ld.so.conf contains/usr/local/python2.7/lib
#vi/etc/ld.so.conf Add/usr/local/python2.7/lib
#/sbin/ldconfig
2. If Python upgrades to 2.7 after Yum unusable, the error is no module named Yum, follow these steps to change the Python version used by Yum to an older version:
Open Yum Execution file
# Vim/usr/bin/yum
Change the first line of #!/usr/bin/python to the original Python version of the backup, as follows:
#!/usr/bin/python_old