Newbie : desperately need help on "import MySQLdb"
John Hunter
jdhunter at ace.bsd.uchicago.edu
Sat Nov 23 11:22:36 EST 2002
>>>>> "Michel" == Michel COMBE <michel.l.combe at free.fr> writes:
Michel> I'm trying to use MySQLdb in a python program. System is
Michel> Linux Mandrake 8.2, Python is installed from rpm in
Michel> /usr/bin MySQLdb is installed from rpm in
Michel> /usr/lib/python2.2/site-packages MySQL version 2.23.53a is
Michel> installed in /var/lib
Michel> If I type import "MySQLdb", I receive the message File
Michel> "/usr/lib/python2.2/site-packages/MySQLdb/__init__.py"
Michel> line 27 ImportError: No module named _mysql
There should be a file named
/usr/lib/python2.2/site-packages/_mysql.so
If not, there is something funny about your rpm install. If you have
run 'updatedb' recently do 'locate _mysql.so' and see where if you
have it. If you do not have 'locate' working, try
fine /usr -name "_mysql.so"
If this file turns up, you need to add it's location to your
PYTHONPATH. Suppose you find it in /usr/lib/someplace. You could do
export PYTHONPATH=/usr/lib/someplace # bash and friends
setenv PYTHONPATH /usr/lib/someplace # csh and friends
If you do not have it, you need to try installing MySQLdb from the
source package. Grab the *.tar.gz src, untar it with, read the README
and then
/usr/bin/python2.2 setup.py install
Cross your fingers and hope the build goes well. If not, reread the
README to see if you can figure out what went wrong, then post back
with the error message and get some more help. No need to waste 2
more days.
John Hunter
More information about the Python-list
mailing list