MySQLdb ImportError: libmysqlclient. so.18 solution, libmysqlclient
An error occurred while importing MySQLdb after installing MySQLdb:
Copy codeThe Code is as follows:
[Root @ lizhong MySQL-python-1.2.3] #/usr/local/bin/python2.7
Python 2.7.6 (default, Apr 10 2014, 15:45:39)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> Import MySQLdb
/Usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_ mysql. py: 3: UserWarning: Module _ mysql was already imported from/usr/local/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg/_ mysql. pyc, but/soft/MySQL-python-1.2.3 is being added to sys. path
Traceback (most recent call last ):
File "<stdin>", line 1, in <module>
File "MySQLdb/_ init _. py", line 19, in <module>
Import _ mysql
File "build/bdist. linux-x86_64/egg/_ mysql. py", line 7, in <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 prompt, the file libmysqlclient. so.18 cannot be found, so you can find this file in the mysql installation directory and make a soft connection to/usr/lib.
Copy codeThe Code is as follows:
Ln-s/usr/local/mysql/lib/libmysqlclient. so.18/usr/lib/libmysqlclient. so.18
For 64 systems:
Copy codeThe Code is as follows:
Ln-s/usr/local/mysql/lib/libmysqlclient. so.18/usr/lib64/libmysqlclient. so.18
Import MySQLdb again and it will be normal:
Copy codeThe Code is as follows:
[Root @ lizhong MySQL-python-1.2.3] #/usr/local/bin/python2.7
Python 2.7.6 (default, Apr 10 2014, 15:45:39)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> Import MySQLdb
>>>
Python script error ImportError No module named MySQLdb
The MySQLdb module is missing
Baidu 'importerror No module named MySQLdb workary'
How to install python's MySQLdb module?
In what version of python do you use, 32-bit or 64-bit?