http://blog.csdn.net/nanaranran/article/details/52184587
[root@mysql1 ~]# cd MySQL-python-1.2.3
[root@mysql1 MySQL-python-1.2.3]# lltotal 160
drwxrwxr-x 2 mycat mycat 4096 Jun 17 2010 doc
-rw-rw-r-- 1 mycat mycat 10285 Jun 17 2010 ez_setup.py
-rw-rw-r-- 1 mycat mycat 3389 Jun 17 2010 HISTORY
-rw-rw-r-- 1 mycat mycat 272 Jun 17 2010 MANIFEST.in
-rw-rw-r-- 1 mycat mycat 2096 Jun 17 2010 metadata.cfg
-rw-rw-r-- 1 mycat mycat 75449 Jun 17 2010 _mysql.c
drwxrwxr-x 3 mycat mycat 4096 Jun 17 2010 MySQLdb
-rw-rw-r-- 1 mycat mycat 2306 Jun 17 2010 _mysql_exceptions.py
drwxrwxr-x 2 mycat mycat 4096 Jun 17 2010 MySQL_python.egg-info
-rw-rw-r-- 1 mycat mycat 1751 Jun 17 2010 PKG-INFO
-rw-rw-r-- 1 mycat mycat 3203 Jun 17 2010 pymemcompat.h
-rw-rw-r-- 1 mycat mycat 6676 Jun 17 2010 README
-rw-rw-r-- 1 mycat mycat 380 Jun 17 2010 setup.cfg
-rw-rw-r-- 1 mycat mycat 951 Jun 17 2010 setup_common.py
-rw-rw-r-- 1 mycat mycat 3225 Jun 17 2010 setup_posix.py
-rw-rw-r-- 1 mycat mycat 531 Jun 17 2010 setup.py
-rw-rw-r-- 1 mycat mycat 1547 Jun 17 2010 setup_windows.py
-rw-rw-r-- 1 mycat mycat 592 Jun 17 2010 site.cfg
drwxrwxr-x 2 mycat mycat 4096 Jun 17 2010 tests
[root@mysql1 MySQL-python-1.2.3]# python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.6
copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.6
creating build/lib.linux-x86_64-2.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-2.6/MySQLdb
creating build/lib.linux-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-2.6
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/mysql/base/include -I/usr/include/python2.6 -c _mysql.c -o build/temp.linux-x86_64-2.6/_mysql.o -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing
In file included from _mysql.c:36:
/mysql/base/include/my_config.h:443:1: warning: "HAVE_WCSCOLL" redefined
In file included from /usr/include/python2.6/pyconfig.h:6,
from /usr/include/python2.6/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/usr/include/python2.6/pyconfig-64.h:808:1: warning: this is the location of the previous definition
gcc -pthread -shared build/temp.linux-x86_64-2.6/_mysql.o -L/mysql/base/lib -L/usr/lib64 -lmysqlclient -lpthread -lm -lrt -ldl -lpython2.6 -o build/lib.linux-x86_64-2.6/_mysql.so
[root@mysql1 MySQL-python-1.2.3]# python setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.6/MySQLdb
running build_ext
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.6/_mysql_exceptions.py -> build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.6/_mysql.so -> build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.6/MySQLdb/release.py -> build/bdist.linux-x86_64/egg/MySQLdb
creating build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.6/MySQLdb/constants/CLIENT.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.6/MySQLdb/constants/__init__.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.6/MySQLdb/constants/CR.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.6/MySQLdb/constants/ER.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.6/MySQLdb/constants/REFRESH.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.6/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.6/MySQLdb/constants/FLAG.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.6/MySQLdb/connections.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.6/MySQLdb/__init__.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.6/MySQLdb/converters.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.6/MySQLdb/times.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.6/MySQLdb/cursors.py -> build/bdist.linux-x86_64/egg/MySQLdb
byte-compiling build/bdist.linux-x86_64/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/times.py to times.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/cursors.py to cursors.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.linux-x86_64/egg/_mysql.py to _mysql.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/MySQL_python-1.2.3-py2.6-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing MySQL_python-1.2.3-py2.6-linux-x86_64.egg
creating /usr/lib64/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg
Extracting MySQL_python-1.2.3-py2.6-linux-x86_64.egg to /usr/lib64/python2.6/site-packages
Adding MySQL-python 1.2.3 to easy-install.pth file
Installed /usr/lib64/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg
Processing dependencies for MySQL-python==1.2.3
Finished processing dependencies for MySQL-python==1.2.3
[root@mysql1 MySQL-python-1.2.3]# python
Python 2.6.6 (r266:84292, Jan 22 2014, 01:49:05)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
>>>
[root@mysql1 MySQL-python-1.2.3]# ln -s /mysql/base/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
[root@mysql1 ~]# python
Python 2.6.6 (r266:84292, Jan 22 2014, 01:49:05)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MYSQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MYSQLdb
>>> import mysqldb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mysqldb
>>> import MYSQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MYSQLdb
>>> import MySQLdb ---------------------------坑人的大小写
>>>