MySQLdb importerror:libmysqlclient.so.18 Solution Method _python

Source: Internet
Author: User

After installing MYSQLDB, the import mysqldb error follows:

Copy Code code 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 the 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, 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 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/usr/lib
Copy Code code as follows:

Ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib/libmysqlclient.so.18

If the 64 system is:
Copy Code code as follows:

Ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib64/libmysqlclient.so.18

Again import MySQLdb is normal:
Copy Code code 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 the more information.
>>> Import MySQLdb
>>>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.