简体   繁体   中英

Importing _mysql in MySQLdb

Why is _mysql in the MySQLdb module a C file? When the module tries to import it, I get an import error. What should I do?

It's the adaptor that sits between the Python MySQLdb module and the C libmysqlclient library. One of the most common reasons for it not loading is that the appropriate libmysqlclient library is not in place.

Edit : This might be the answer to your question.

When I try to import _mysql , I get no error:

import _mysql
print(_mysql)
# <module '_mysql' from '/usr/lib/pymodules/python2.6/_mysql.so'>

It is importing the library /usr/lib/pymodules/python2.6/_mysql.so

If this is not what you are getting, it sounds like an installation error. What OS are you using? How did you install mysqldb?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM