When importing the MySQLdb module, the error is as follows
>>> Import MySQLdb
Traceback (most recent):
File "<stdin>", line 1, in <module>
Importerror:no module named MySQLdb
Found a solution on the Internet:
Yum Install Mysql-python (CentOS System)
Import again when the error, suspect is the version issue:
$ python--version
Python 2.7.10
$ cat/etc/issue
CentOS release 5.11 (Final)
Kernel \ r on an \m
This version of the system is installed by default with the python2.4 module:
$ RPM-QL Mysql-python
/usr/lib64/python2.4/site-packages/mysql_python-1.2.3c1-py2.4.egg-info
/usr/lib64/python2.4/site-packages/mysql_python-1.2.3c1-py2.4.egg-info/pkg-info
/usr/lib64/python2.4/site-packages/mysql_python-1.2.3c1-py2.4.egg-info/sources.txt
/usr/lib64/python2.4/site-packages/mysql_python-1.2.3c1-py2.4.egg-info/dependency_links.txt
/usr/lib64/python2.4/site-packages/mysql_python-1.2.3c1-py2.4.egg-info/top_level.txt
/usr/lib64/python2.4/site-packages/mysqldb
........
........
Workaround:
1, download mysql-python-1.2.5 on official website. Https://pypi.python.org/pypi/MySQL-python
2,unzip Mysql-python-1.2.5.zip
3, installation
CD mysql-python-1.2.5
Python setup.py Build
Python setup.py Install
Loading the module again is an error:
>>> Import MySQLdb
Traceback (most recent):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/mysqldb/__init__.py", line A, in <module>
File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, <module>
File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__
Importerror:libmysqlclient.so.18:cannot open Shared object file:no such file or directory
According to the last hint, should be unable to find a libmysqlclient.so.18 file, so go to the MySQL installation directory to find this file and make a soft connection to the/usr/lib
ln-sv/usr/local/ver01/percona/lib/libmysqlclient.so.18/usr/lib64/libmysqlclient.so.18
No more error when loading the module again.
This article is from the "Always on the Road" blog, please be sure to keep this source http://chenql.blog.51cto.com/8732050/1760899
Already installed Mysql-python, but in quoting the Times wrong: Importerror:no module named MySQLdb